2014-12-03 83 views

回答

0

有兩種使用文件的方式。您可以將其標記爲

  • 資源文件:編譯爲可執行文件或庫程序集的數據文件。訪問資源,

例子:

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); 
} 
+0

請U將共享全碼 – 2014-12-03 08:51:00

+0

錯誤\t \t 1的「等待」操作符只能異步方法內使用。考慮使用「異步」修飾符標記此方法,並將其返回類型更改爲「任務」。 \t在代碼 – 2014-12-03 09:05:43

+0

中顯示的D:\ VisualStudioProjects \ GK \ GK \ MainPage.xaml.cs錯誤將async關鍵字添加到您的函數標題,如'async void openPDF()' – 2014-12-03 09:07:38

相關問題