1
我寫了一個簡單的函數來將文件從SkyDrive下載到IsolatedStorage中。爲什麼LiveConnectClient.BackgroundDownloadAsync嘗試「等待」它失敗?
public static async Task<T> DownloadFileData<T>(string fileID, string filename)
{
var liveClient = new LiveConnectClient(Session);
// Download the file
await liveClient.BackgroundDownloadAsync(fileID + "/Content", new Uri("/shared/transfers/" + filename, UriKind.Relative));
// Get a reference to the Local Folder
string root = ApplicationData.Current.LocalFolder.Path;
var storageFolder = await StorageFolder.GetFolderFromPathAsync(root + @"\shared\transfers");
// Read the file
var FileData = await StorageHelper.ReadFileAsync<T>(storageFolder, filename);
return FileData;
}
函數失敗運行線路:
// Download the file
await liveClient.BackgroundDownloadAsync(fileID + "/Content", new Uri("/shared/transfers/" + filename, UriKind.Relative));
出現錯誤: 「‘System.InvalidOperationException’類型的異常出現在mscorlib.ni.dll但在用戶代碼中沒有處理
請求已提交」如果我修改線(去除的await)
函數成功:
// Download the file
liveClient.BackgroundDownloadAsync(fileID + "/Content", new Uri("/shared/transfers/" + filename, UriKind.Relative));
這是爲什麼?
THX
你是什麼意思「失敗」嗎?它是否陷入僵局?是否有例外? –
我得到的錯誤是: 「在mscorlib.ni.dll中發生類型爲'System.InvalidOperationException'的異常,但未在用戶代碼中處理 請求已提交」 –
您的代碼是否提交該請求超過一旦? –