我创建了以下代码,从已安装程序的根目录中打开.pdf文件。
private void HelpButton_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "Help Me.pdf";
proc.Start();
}
问题在于该程序一旦安装并从桌面图标启动,将无法打开.pdf文件。但是,从桌面快捷方式指向的实际文件启动时,该按钮可以很好地打开文件。我还尝试了以下方法,效果相同。
private void HelpButton_Click(object sender, RoutedEventArgs e)
{
ProcessStartInfo helpInfo = new ProcessStartInfo("Help Me.pdf");
helpInfo.WorkingDirectory = Assembly.GetExecutingAssembly().ToString();
Process.Start(helpInfo);
}
private void HelpButton_Click(object sender, RoutedEventArgs e)
{
ProcessStartInfo helpInfo = new ProcessStartInfo("Help Me.pdf");
Process.Start(helpInfo);
}
private void HelpButton_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("Help Me.pdf");
}
任何帮助将不胜感激