Windows phone 8.1 如何从windows phone 8.1中的Url将pdf文件获取到临时存储文件 var uri=new System.uri(“ms-appx:///Assets/FixesViaMail_17Dec.pdf“,乌里金。绝对); StorageFile file=等待Windows.Storage.StorageFile.GetFileFromApplicationUrisync(uri);

Windows phone 8.1 如何从windows phone 8.1中的Url将pdf文件获取到临时存储文件 var uri=new System.uri(“ms-appx:///Assets/FixesViaMail_17Dec.pdf“,乌里金。绝对); StorageFile file=等待Windows.Storage.StorageFile.GetFileFromApplicationUrisync(uri);,windows-phone-8.1,Windows Phone 8.1,这段代码运行得很好,因为我使用的是我的系统文件路径,但每当我使用这段代码时 var uri=new System.uri(“http://www.visa.com/assets/upload/11458/Hotel/Voucher114581423144270.pdf“,乌里金。绝对); StorageFile file=等待Windows.Storage.StorageFile.GetFileFromApplicationUrisync(uri); 然后我得到的错误是。。。。。 值不在预期范

这段代码运行得很好,因为我使用的是我的系统文件路径,但每当我使用这段代码时

var uri=new System.uri(“http://www.visa.com/assets/upload/11458/Hotel/Voucher114581423144270.pdf“,乌里金。绝对);
StorageFile file=等待Windows.Storage.StorageFile.GetFileFromApplicationUrisync(uri);
然后我得到的错误是。。。。。 值不在预期范围内


请帮助我

GetFileFromApplicationUriAsync仅用于从应用程序中加载文件。要从web读取文件,您需要下载它。您可以使用(对于小文件)或(对于大文件)类来实现这一点

var uri=新uri(“http://www.visa.com/assets/upload/11458/Hotel/Voucher114581423144270.pdf");
var httpClient=新的httpClient();
//始终捕获异步方法的网络异常
尝试
{
var response=wait-httpClient.GetAsync(uri);
//保存响应
}
抓住
{
//ex.Message和ex.HResult中的详细信息。
}
有关更多详细信息,请参阅

var uri=新uri(“http://www.visa.com/assets/upload/11458/Hotel/Voucher114581423144270.pdf");
BackgroundDownloader download=新的BackgroundDownloader();
DownloadOperation download=downloader.CreateDownload(uri,destinationFile);

有关更多详细信息,请参阅。

Hi Romasz,谢谢,但请告诉我如何获取此类文件的流,如我需要的下一行代码。。使用(Stream Stream=wait file.OpenStreamForReadAsync()){Document doc=new Document(Stream);Apitron.PDF.Rasterizer.Page=doc.Pages[0];ErrorLogger=new ErrorLogger();WriteableBitmap bm=Page.Render((int)Page.Width,(int)page.Height,new RenderingSettings(),logger);myImage.Source=bm;}但我得到了一个错误——文档加载错误