如何调出"Windows无法打开此文件"对话框?

Ang*_*ker 5 c# visual-studio-2005 file-association process.start

我的用户可以将文档附加到应用程序中的各种实体.当然,如果用户A附加.TIFF文件,则用户B可能没有该类型文件的查看器.

所以我希望能够提出这个对话框:

alt text http://www.angryhacker.com/toys/cannotopen.png

我的应用程序是带VS2005的C#.
目前我做Process.Start并传入文件名.如果未找到关联,则会引发异常.

小智 13

Process pr = new Process();
pr.StartInfo.FileName = fileTempPath;
pr.StartInfo.ErrorDialog = true; // important
pr.Start();
Run Code Online (Sandbox Code Playgroud)


Jay*_*ggs 7

这应该这样做:

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "rundll32.exe";
p.StartInfo.Arguments = "shell32.dll,OpenAs_RunDLL " + yourFileFullnameHere;

p.Start();
Run Code Online (Sandbox Code Playgroud)