1

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 ?

Jay Riggs
  • 53,046
  • 9
  • 139
  • 151
rekna
  • 5,313
  • 7
  • 45
  • 54

1 Answers1

2

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.

Community
  • 1
  • 1
Jay Riggs
  • 53,046
  • 9
  • 139
  • 151
  • I tried this solution as well, but it gives even worse results on vista... XP does not seem to have that problem. – rekna Oct 30 '09 at 23:52
  • 1
    using System; using System.Diagnostics; using System.IO; public static void ShowOpenWithDialog(string path) { var args = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "shell32.dll"); args += ",OpenAs_RunDLL " + path; Process.Start("rundll32.exe", args); } This code seems to work on Win8 and Win7 could anyone confirm on Vista and XP – rekna Jun 02 '13 at 15:38