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

后端 未结 3 1543
无人共我
无人共我 2020-12-21 02:38

I have a winfrom 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

相关标签:
3条回答
  • 2020-12-21 03:13
    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
    
    0 讨论(0)
  • 2020-12-21 03:16

    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”)
    
    0 讨论(0)
  • 2020-12-21 03:30

    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.

    0 讨论(0)
提交回复
热议问题