c# 打开文件总是显示“打开方式”对话

发布于 2024-08-09 07:14:02 字数 369 浏览 2 评论 0原文

我有 ac# 应用程序,它下载文件,并且应该始终显示“打开方式”对话框,无论扩展名是否是已知扩展名。

我尝试过

global::System.Diagnostics.Process.Start("rundll32.exe",
                string.Format("shell32.dll,OpenAs_RunDLL \"{0}\"", filename));

,但是当我尝试打开 .png 文件时,“打开方式”对话框不会显示,并且该文件会使用我的默认图像查看器打开。

用户应该能够选择一个应用程序(例如,他可能想编辑文件而不是查看文件)。有没有办法强制 Vista 显示打开对话框,以便用户可以选择?

I have a c# application, which downloads a file, and should always show the Open With dialog, regardless if the extension is a known extension or not.

I tried

global::System.Diagnostics.Process.Start("rundll32.exe",
                string.Format("shell32.dll,OpenAs_RunDLL \"{0}\"", filename));

but, when I try to open a .png file, the "Open With" dialog does not show and the file gets opened with my default image viewer.

The user should be able to choose an application (eg. maybe he wants to edit the file instead of viewing it). Is there a way to force Vista to show the open with dialog, so the user can choose ?

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

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

发布评论

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

评论(1

执着的年纪 2024-08-16 07:14:02

我相信这篇文章就是您正在寻找的内容:

从以下位置调用“打开方式”对话框您的应用程序,使用 C#

该代码也应该可以在 Vista 中运行。

This article is what you're looking for, I believe:

Calling the Open With dialog box from your application, using C#

The code should work in Vista too.

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