0
我需要從windows phone 8應用程序的資產文件夾中打開pdf文檔文件。首先,我需要檢查是否有任何pdf閱讀器可用,如果可用,應從資產文件夾打開pdf文檔。如何通過Windows Phone 8應用程序打開來自資產文件夾的PDF文檔
我需要從windows phone 8應用程序的資產文件夾中打開pdf文檔文件。首先,我需要檢查是否有任何pdf閱讀器可用,如果可用,應從資產文件夾打開pdf文檔。如何通過Windows Phone 8應用程序打開來自資產文件夾的PDF文檔
有兩種使用文件的方式。您可以將其標記爲
例子:
Stream jsStream = Application.GetResourceStream(new Uri("folder\\e_data.pdf",UriKind.Relative)).Stream;
訪問內容的文件,在屬性中使用
Uri filePath = new Uri(@"ms-appx:///example.pdf");
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync();
例
標記PDF文件作爲content
- >生成操作。
async void openPDF()
{
Uri filePath = new Uri(@"ms-appx:///example.pdf");
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(filePath);
//For opening that file,
if (file != null)
await Launcher.LaunchFileAsync(file);
}
請U將共享全碼 – 2014-12-03 08:51:00
錯誤\t \t 1的「等待」操作符只能異步方法內使用。考慮使用「異步」修飾符標記此方法,並將其返回類型更改爲「任務」。 \t在代碼 – 2014-12-03 09:05:43
中顯示的D:\ VisualStudioProjects \ GK \ GK \ MainPage.xaml.cs錯誤將async關鍵字添加到您的函數標題,如'async void openPDF()' – 2014-12-03 09:07:38