首页 > 解决方案 > Process.Start() 不提示应用程序选择

问题描述

当双击具有未知文件类型的文件时,windows 会弹出一个窗口,允许我选择要使用哪个应用程序打开文件。

我正在尝试使用以下代码在我的应用程序中打开文件,直到最近我才得到相同的结果

   var startInfo = new ProcessStartInfo(document.DownloadPath);
   startInfo.UseShellExecute = true;
   Process.Start(startInfo);                  

当我转到应用程序的其他部分时,我不知道它何时停止工作,但现在尝试打开扩展名未知的文件时出现以下错误。

System.ComponentModel.Win32Exception (1155): No application is associated with the specified file for this operation.
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)

使用我的应用程序打开或实际双击文件时,如何获得相同的体验?

标签: c#

解决方案


推荐阅读