简体   繁体   English

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

[英]c# open file always show “Open With” dialog

I have ac# application, which downloads a file, and should always show the Open With dialog, regardless if the extension is a known extension or not. 我有一个ac#应用程序,该应用程序下载文件,并且无论扩展名是否为已知扩展名,都应始终显示“打开方式”对话框。

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. 但是,当我尝试打开.png文件时,“打开方式”对话框不显示,并且使用默认的图像查看器打开了该文件。

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 ? 有没有一种方法可以强制Vista显示打开方式对话框,以便用户选择?

This article is what you're looking for, I believe: 我相信您正在寻找这篇文章:

Calling the Open With dialog box from your application, using C# 使用C#从应用程序中调用“打开方式”对话框

The code should work in Vista too. 该代码也应在Vista中工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM