C # How to open a PDF file in my project resources?

I have a winfrom GUI that has a "help" context menu. When clicked, I would like to open the user guide for the application. The manual is a pdf file that is stored in the application resources.

Question: How do I open this for the user?

The code I'm working with

System.Diagnostics.Process process = new System.Diagnostics.Process(); bool adobeInstall = false; RegistryKey adobe = Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Adobe"); if (adobe != null) { RegistryKey acroRead = adobe.OpenSubKey("Acrobat Reader"); if (acroRead != null) adobeInstall = true; } if (adobeInstall == true) { ///Open the pdf file?? } 
+4
source share
3 answers
 string locationToSavePdf = Path.Combine(Path.GetTempPath(), "file name for your pdf file.pdf"); // select other location if you want File.WriteAllBytes(locationToSavePdf,Properties.Resources.nameOfFile); // write the file from the resources to the location you want Process.Start(locationToSavePdf); // run the file 
+6
source

Try this (you only need the path to the PDF file, there is no need to add it to the resource):

 using System.Diagnostics; Process.Start("Path_of_PDFFile") 
+1
source

Add using System.Diagnostics; to your use, and then call:

Process.Start("path to pdf")

You will not need to search for PDF Reader exe or anything else. Just call the path to the file you want.

+1
source

All Articles