我正在使用以下代码段下载大型视频(大小:小于14MB)。它在Windows Phone 8.1设备中工作正常但在Windows Phone 10设备中执行相同时会永远卡住。 它在Windows Phone 10设备中下载小文件(大小约为1MB),但在下载大型视频文件时不会出现任何异常而永久停留。
try
{
Uri uri = new Uri(url + "?refresh=" + Guid.NewGuid().ToString());
var httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromMinutes(3);
var httpResponse = await httpClient.GetAsync(uri);
httpResponse.EnsureSuccessStatusCode();
byte[] dataByte = await httpResponse.Content.ReadAsByteArrayAsync();
StorageFolder appFolder = ApplicationData.Current.LocalFolder;
StorageFile file = await appFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
await FileIO.WriteBytesAsync(file, dataByte);
return "success";
}
catch (Exception ex)
{
throw new Exception();
}