WPF打开pdf文件

前提:

SumatraPDF.exe 执行程序存放位置 : ...(项目位置)\bin\Debug\config\

help_zh.pdf 打开的文件存放位置:  ...(项目位置)\bin\Debug\config\

 

1.调用 pdf.exe,打开pdf文件

public void OpenHelpDoc()
        {
            try
            {
                string path = m_mainwin.GetConfigPath() + "help_zh.pdf";
                System.Diagnostics.Process.Start(m_mainwin.GetConfigPath() + @"\SumatraPDF.exe", "\"" + path + "\"");
            }
            catch(Exception ex)
            {
                Cursor.Current = Cursors.Default;
                Utils.ShowMessageBox(App.GetString("ID_LG_25"), false,true);
                MainWindow.ErrorMessagee("HelpDocument->OpenHelpDoc", ex);
            }
        }

2.获取项目config目录

        public string GetConfigPath()
        {
            try
            {
                System.IO.DirectoryInfo topDir = System.IO.Directory.GetParent
                               (System.Windows.Forms.Application.ExecutablePath);
                string path = topDir.ToString() + "\\config\\";

                if (!(Directory.Exists(path)))
                {
                    Directory.CreateDirectory(path);
                }
                return path;
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }

 

你可能感兴趣的:(WPF)