我正在研究WP8.1 WinRT项目。我正在下载文件并试图打开它但我收到错误?我的代码出了什么问题?
private async void HandleDownloadAsync(DownloadOperation download, bool start)
{
try
{
Progress<DownloadOperation> progressCallback = new Progress<DownloadOperation>(ProgressCallback);
if (start)
{
await download.StartAsync().AsTask(cts.Token, progressCallback);
}
else
{
await download.AttachAsync().AsTask(cts.Token, progressCallback);
}
ResponseInformation response = download.GetResponseInformation();
}
catch (Exception ex)
{
Debug.WriteLine("Error HandleDownloadAsync: {0}", ex);
}
finally
{
OpenFile();
}
}
private async void OpenFile()
{
try
{
StorageFile fileToLaunch = await KnownFolders.PicturesLibrary.GetFileAsync(medNameChosen");
if (destinationFile.ToString() != null)
{
await Windows.System.Launcher.LaunchFileAsync(fileToLaunch);
}
}
catch (Exception ex)
{
Debug.WriteLine("Error: {0}", ex);
}
}
运行下面的代码后,我收到以下错误:
Error: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at Windows.System.Launcher.LaunchFileAsync(IStorageFile file)
at PM.Page.<OpenFile>d__1f.MoveNext()