问题描述
我在这里有一个UWP应用。在这个UWP应用中,我正在下载文件。注意到在另一个国家,他们的防火墙阻止了下载,并且UWP App冻结了。在他们的计算机上调试时,我注意到在await RandomAccessStream.CopyAndCloseAsync(inputStream,outputStream);
之后,UWP App只是冻结了,下一步永远不会在调试模式下发生。您无法再在UWP App中执行任何操作。
我可以通过在await RandomAccessStream.CopyAndCloseAsync(inputStream,outputStream);
之前断开与互联网的连接来在计算机上重新创建它。当重新连接到Internet时,将进入调试模式的下一步,UWP App的工作原理与以前一样好。
现在我不知道...是什么原因导致此问题?我需要await RandomAccessStream.CopyAndCloseAsync(inputStream,outputStream);
的Internet连接吗?以及如何解决它,使其仅忽略await RandomAccessStream.CopyAndCloseAsync(inputStream,outputStream);
这个步骤?
async public Task DownloadFile(Uri url,string filename)
{
Windows.Web.Http.HttpResponseMessage response = await client.GetAsync(url,Windows.Web.Http.HttpCompletionOption.ResponseHeadersRead);
response.EnsureSuccessStatusCode();
var responseBody = await response.Content.ReadAsInputStreamAsync();
IInputStream inputStream = await response.Content.ReadAsInputStreamAsync();
StorageFolder folder = await App.GetDocumentFolder();
StorageFile file = await folder.CreateFileAsync(filename,CreationCollisionOption.ReplaceExisting);
IOutputStream outputStream = await file.OpenAsync(FileAccessMode.ReadWrite);
await RandomAccessStream.CopyAndCloseAsync(inputStream,outputStream);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)