我编写了一个简单的函数来将文件从 SkyDrive 下载到 IsolatedStorage。
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 ) );
出现错误:“在 mscorlib.ni.dll 中发生‘System.InvalidOperationException’类型的异常,但未在用户代码中处理
请求已经提交”
如果我将行修改为(删除等待),则该函数成功:
// Download the file
liveClient.BackgroundDownloadAsync( fileID + "/Content", new Uri( "/shared/transfers/" + filename, UriKind.Relative ) );
这是为什么?
谢谢