我有一个WPF应用程序,可以打开存储在磁盘上的.pdf文件。如何将这些.pdf文件包含到项目中,以便文件作为应用程序安装的一部分?
答案 0 :(得分:1)
只需将.pdf文件放入项目的根目录
即可答案 1 :(得分:1)
我会将与其余app文件分开的数据存储在自己的目录中,但是存储在project / solution目录中。将您的pdf文件放在此目录中,并使用静态类/字符串来存储此文件夹的(相对)位置;另一个好的做法是在json文件中设置目录位置。在WPF端,指向此商店位置的ListBox
或directory.getfiles
以获取您的pdf列表。
答案 2 :(得分: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.