Reputation: 5658
I have a WPF application that opens .pdf files stored on the disk. How should one include those .pdf files into the project so that the files will come as part of the application installation?
Upvotes: 0
Views: 931
Reputation: 5658
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.
Upvotes: 0
Reputation: 7287
I would store the data separated from the rest of the app files, in its own directory, but in the project/solution directory. Put your pdf files in this directory and use a static class/string to store the (relative) location of this folder; another good practice is to set the directory location in a json file. On the WPF side, have a ListBox
pointing to this store location, or a directory.getfiles
to get the list of your pdfs.
Upvotes: 1
Reputation: 321
Just place .pdf files in to the root directory of your project
Upvotes: 1