How to open a PDF file that is also a project resource?

后端 未结 8 1868
星月不相逢
星月不相逢 2021-01-17 19:35

I have a PDF file that I have imported in as a resource into my project. The file is a help document so I want to be able to include it with every deployment. I want to be a

相关标签:
8条回答
  • 2021-01-17 20:03
    //create a temporal file
    string file = Path.GetTempFileName() + ".pdf";
    //write to file
    File.WriteAllBytes(file, Properties.Resources.PDF_DOCUMENT);
    //open with default viewer
    System.Diagnostics.Process.Start(file);
    
    0 讨论(0)
  • 2021-01-17 20:04

    Check this out easy to open pdf file from resource.

    private void btnHelp_Click(object sender, EventArgs e)
        {            
            String openPDFFile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\HelpDoc.pdf";//PDF DOc name
            System.IO.File.WriteAllBytes(openPDFFile, global::ProjectName.Properties.Resources.resourcePdfFileName);//the resource automatically creates            
            System.Diagnostics.Process.Start(openPDFFile);             
        }   
    
    0 讨论(0)
提交回复
热议问题