Search code examples
c#windows-7windows-vistaopenfiledialogsavefiledialog

How to open new OpenFileDialog automatically in Vista/Win7?


I'm on Vista and I'm using Microsoft.Win32.OpenFileDialog class.

When I call ShowDialog() I get the old XP-style dialog: alt text

How do I get the new Vista-style dialog with fallback to the old one on WindowsXP? alt text

A bit of rumble:

I don't really understand why they didn't replace the dialog in vista, but kept both of them. Now legacy apps will never open new dialog, unless updated.


Solution

  • Yes, you'd have to upgrade to .NET 4.0 to get the new dialog. If you're stuck on 3.5 then you can use System.Windows.Forms.OpenFileDialog, it did get the update to use the new IFileDialog COM interface.

    The fallback is automatic but you can use its AutoUpgradeEnabled property to force legacy, if necessary. Which it is not, unlikely that a .NET program would modify the dialog.