如何调出“Windows 无法打开此文件” 对话?

发布于 2024-07-20 07:05:33 字数 313 浏览 6 评论 0原文

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

所以我希望能够打开这个对话框:

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

我的应用程序是使用 VS2005 的 C#。
目前我执行 Process.Start 并传入文件名。 如果没有找到关联,则会抛出异常。

My users can attach documents to various entities in the application. Of course, if user A attaches a .TIFF file, user B may not have a viewer for that type of file.

So I'd like to be able to bring up this dialog:

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

My application is C# with VS2005.
Currently I do Process.Start and pass in the file name. If no association is found, it throws an exception.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我一向站在原地 2024-07-27 07:05:33
Process pr = new Process();
pr.StartInfo.FileName = fileTempPath;
pr.StartInfo.ErrorDialog = true; // important
pr.Start();
Process pr = new Process();
pr.StartInfo.FileName = fileTempPath;
pr.StartInfo.ErrorDialog = true; // important
pr.Start();
夏见 2024-07-27 07:05:33

这应该可以做到:

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

p.Start();

This should do it:

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

p.Start();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文