如何在 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 位于我的项目资源库中,属性 "Copy to Output Directory" 设置为 "Copy always"。
运行 此代码导致以下错误:System.ArgumentException: 'Value does not fall within the expected range.'
解决此问题的正确语法是什么?
你可以试试:
var file = await StorageFile.
GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/template.pdf"));
在我的 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 位于我的项目资源库中,属性 "Copy to Output Directory" 设置为 "Copy always"。
运行 此代码导致以下错误:System.ArgumentException: 'Value does not fall within the expected range.'
解决此问题的正确语法是什么?
你可以试试:
var file = await StorageFile.
GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/template.pdf"));