繁体   English   中英

如何在 UWP 中引用 StorageFile class 的文件?

[英]How to reference a file for StorageFile class in UWP?

在我的 UWP 项目中,我正在尝试使用 Syncfusion 的 PDF 库来填写 PDF 。 为了打开我想使用的模板,我构建了以下代码:

//Browse and chose the file
Windows.Storage.StorageFolder storageFolder 
= Windows.Storage.ApplicationData.Current.LocalFolder;

StorageFile file 
= await storageFolder.GetFileAsync("/Assets/template.pdf");

//Creates an empty PDF loaded document instance
PdfLoadedDocument loadedDocument = new PdfLoadedDocument();

//Loads or opens an existing PDF document through Open method of PdfLoadedDocument class
await loadedDocument.OpenAsync(file);

PDF,template.pdf,位于项目中我的资产库中,其属性“复制到 Output 目录”始终设置为“Copy to Output 目录”。

运行此代码会导致以下错误: System.ArgumentException:'值不在预期范围内。'

什么是正确的语法来解决这个问题?

你可以试试:

var file = await StorageFile.
     GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/template.pdf"));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM