我无法通过我的 Windows 商店应用程序下载文件。这是我的下载方法:
private static async void DownloadImage()
{
HttpClient client = new HttpClient();
HttpResponseMessage message = await client.GetAsync("http://coolvibe.com/wp-content/uploads/2010/05/scifiwallpaper1.jpg");
StorageFolder myfolder = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFile sampleFile = myfolder.CreateFileAsync("image.jpg", CreationCollisionOption.ReplaceExisting).GetResults();// this line throws an exception
byte[] file = await message.Content.ReadAsByteArrayAsync();
await FileIO.WriteBytesAsync(sampleFile, file);
var files = await myfolder.GetFilesAsync();
}
在标记的行上,我得到了这个异常:
An exception of type 'System.InvalidOperationException' occurred in ListStalkerWin8.exe but was not handled in user code
WinRT information: A method was called at an unexpected time.
Additional information: A method was called at an unexpected time.
这可能是什么原因造成的?