4

I have a WinForms GUI that has a 'help' context menu. When clicked, I would like to open the user manual for the application. The manual is a pdf which is stored within the application resources.

Question: How do I open this for the user?

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??
}
Vizel Leonid
  • 456
  • 7
  • 15
stackoverflow
  • 18,348
  • 50
  • 129
  • 196

3 Answers3

6
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
coolmine
  • 4,427
  • 2
  • 33
  • 45
  • +1, except you may wish to use `Path.Combine` instead of string.Format... Also, don't forget to clean up after viewing the file! – sǝɯɐſ Mar 26 '13 at 16:36
  • Good idea about the Path.Combine, thanks. As for the cleaning I will leave that to Mrshll187 since he might want to write the file in the application folder instead of the temp so no cleaning would be needed then. – coolmine Mar 26 '13 at 16:39
1

Try this (you need just a path to the PDF file, no need to add it to the resource):

using System.Diagnostics;

Process.Start(“Path_of_PDFFile”)
Leo Chapiro
  • 13,678
  • 8
  • 61
  • 92
1

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

Process.Start("path to pdf")

You won't need to find the PDF Reader exe or anything. Just call the path of the file you want.

PiousVenom
  • 6,888
  • 11
  • 47
  • 86