2017-08-19 35 views

回答

1

只需將.pdf文件到您的項目的根目錄

1

我將存儲從應用程序文件的其餘部分分離,在其自身的目錄中的數據,但在項目/解決方案目錄。把你的PDF文件放在這個目錄下,並使用靜態類/字符串來存儲這個文件夾的(相對)位置;另一個好的做法是在json文件中設置目錄位置。在WPF方面,請指向此商店位置的ListBox或獲得您的pdf列表的directory.getfiles

0
I have eventually settled on using Resources as pdf storage. 
So the steps include: 
1. Open project's Properties. Select Resources. A blank white window will appear. 
2. Dragg the files (in this case the .pdf's) onto this window. 
3. A new folder in Project Explorer will appear called Resources, and all the added files will be in the folder. 
4. Select all files in the Resources folder and changed Build Action to Embedded Resource. 
5. To accesses the .pdf files, 

string pDF = Path.Combine(Path.GetTempPath(), "Name of the Pdf.pdf"); 
      File.WriteAllBytes(pDF, YouProjectName.Properties.Resources.Name of the Pdf); 
6. To open pdf 
Process.Start(pDF); 

I found it convenient to have the .pdfs be embedded into AppName.exe. 
相關問題