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' 型の例外が発生しましたが、ユーザー コードで処理されませんでした。
リクエストはすでに送信されています」
行を (await を削除して) 変更すると、関数は成功します。
// Download the file
liveClient.BackgroundDownloadAsync( fileID + "/Content", new Uri( "/shared/transfers/" + filename, UriKind.Relative ) );
何故ですか?
どうも