如何打开也是项目资源的PDF文件?

Ada*_*eck 8 .net c# pdf embedded-resource visual-studio-2008

我有一个PDF文件,我已将其作为资源导入到我的项目中.该文件是一个帮助文档,因此我希望能够将其包含在每个部署中.我希望能够通过单击按钮打开此文件.

我已将构建操作设置为"Embedd Resource".所以现在我希望能够打开它.但是,当我尝试访问资源时My.Resources.HelpFile- 它是一个字节数组.如果我知道最终用户有一个适合打开PDF文档的程序,我该如何打开这个?

如果我错过了上一个问题,请指出正确的方向.我发现了几个关于应用程序中打开PDF的问题,但我不在乎Adobe Reader是否单独打开.

小智 15

从资源中查看这个易于打开的pdf文件.

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);             
    }   
Run Code Online (Sandbox Code Playgroud)


Ada*_*dam 7

创建一个新流程:

string path = Path.Combine(Directory.GetCurrentDirectory(), "PDF-FILE.pdf");
Process P = new Process {
    StartInfo = {FileName = "AcroRd32.exe", Arguments = path}
};
P.Start();
Run Code Online (Sandbox Code Playgroud)

为了使其工作,必须将Visual Studio设置 Copy to Output Directory设置Copy Always为PDF文件.