我有一個WPF應用程序打開存儲在磁盤上的.pdf文件。應該如何將這些.pdf文件包含到項目中,以便這些文件將成爲應用程序安裝的一部分?如何使用PDF文件作爲WPF應用程序的資源
0
A
回答
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.
相關問題
- 1. 使用Excel文件作爲Java程序的資源文件
- 2. 將WPF本地資源轉換爲應用程序資源
- 3. WPF應用程序插件使用來自主機應用程序的資源
- 4. WPF風格的應用程序資源
- 5. 如何使用XPSDocument將包含在WPF應用程序中的XPS文件作爲二進制資源打開?
- 6. WPF:使應用程序資源覆蓋usercontrol庫資源
- 7. 如何爲控制檯應用程序創建資源文件?
- 8. 如何爲android應用程序提供一些資源文件?
- 9. 如何爲WinForm應用程序創建全局資源文件?
- 10. 如何使用cURL POST PDF內容作爲應用程序/ pdf
- 11. 基於默認資源文件爲應用程序生成資源文件
- 12. 使用文件作爲URLClassLoader的資源
- 13. 訪問WPF用戶控件庫中的應用程序資源
- 14. WPF資源字典在應用程序資源
- 15. 如何訪問MVVM WPF應用程序中的圖像資源?
- 16. 使用File.Open作爲WPF資源
- 17. 使用WPF中的資源翻譯應用程序
- 18. 如何使用資源文件(txt - 製表符分隔)作爲win32應用程序的數據源
- 19. 如何在JSF應用程序中引用文件資源
- 20. 在WinForms應用程序中使用WPF,應用程序資源放在哪裏?
- 21. 如何使用JavaScript文件作爲資源文件
- 22. 如何使用cmake和MinGW使用資源文件構建Win32應用程序?
- 23. 如何刷新Web應用程序的資源文件夾?
- 24. 如何捆綁angular4應用程序中的資源文件夾?
- 25. 如何將文件添加到UWP應用程序的資源?
- 26. 使用Swing應用程序框架的資源文件
- 27. 使用不同的資源文件啓動android應用程序
- 28. 安卓應用程序資產文件夾中的pdf文件
- 29. WPF應用程序顯示PDF文檔
- 30. 如何在使用Azure作爲媒體資源(CDN)時更正我的WPF應用程序中的錯誤?