c# open file always show “Open With” dialog

早过忘川 提交于 2019-12-13 18:19:14

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/1652746/c-sharp-open-file-always-show-open-with-dialog

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!