c#打开文件始终显示“打开方式";对话

编程入门 行业动态 更新时间:2024-10-09 19:21:28
本文介绍了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#打开文件始终显示“打开方式";对话

本文发布于:2023-11-13 06:17:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583674.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方式   文件   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!