c#打开文件始终显示“打开方式";对话 [英] c# open file always show "Open With" dialog

查看:205
本文介绍了c#打开文件始终显示“打开方式";对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个c#应用程序,可以下载文件,并且无论扩展名是否为已知扩展名,都应始终显示打开方式"对话框.

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.

我尝试了

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

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

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.

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

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 ?

推荐答案

我相信您正在寻找这篇文章:

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

使用C#从应用程序中调用打开方式"对话框

该代码也应在Vista中工作.

The code should work in Vista too.

这篇关于c#打开文件始终显示“打开方式";对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆