6

I'm remaking on Visual Studio (on C# WPF application mode) an application made on AutoPlay media Studio.

When I needed get files from computer, I found on StackOverflow and in other sites a code to do it, using OpenFileDialog(); but this code shows the older dialog:

enter image description here

But, on the Application made in AMS, the "Open File" is the "Modern" Dialog Window.

Is there any way to Show the "modern" Open File dialog on C# WPF?

Jon
  • 2,566
  • 6
  • 32
  • 52
Kennedy Souza
  • 164
  • 1
  • 13
  • When I made this post, I didn't have enough reputation. – Kennedy Souza Apr 13 '15 at 02:04
  • Are you using `System.Windows.Forms.OpenFileDialog` or `Microsoft.Win32.OpenFileDialog`? Btw both work the same on my machine, but I have Windows 7 (your screenshot looks like Vista). – vesan Apr 13 '15 at 02:05
  • Microsoft.Win32.OpenFileDialog – Kennedy Souza Apr 13 '15 at 02:06
  • Yes, I have Windows 7. – Kennedy Souza Apr 13 '15 at 02:06
  • 1
    possible duplicate? http://stackoverflow.com/a/3885370/361100 – Youngjae Apr 13 '15 at 02:12
  • For me, it turned out that having `.ShowHelp = true` in `OpenFileDialog` in a .NET 4.8 project was the problem. When `ShowHelp = true` WinForms will show the old version for some reason. Setting `ShowHelp = false` caused the new version to appear. Yet another WinForms gotcha. – Dai Mar 05 '21 at 16:15

2 Answers2

2

Thanks vesan, I changed Microsoft.Win32.OpenFileDialog to System.Windows.Forms.OpenFileDialog, and now the code shows the "Modern" Open File Dialog!

Now I just have to adjust the code to work completely.

Kennedy Souza
  • 164
  • 1
  • 13
  • Not sure why, but both versions of `OpenFileDialog` have the exact same "modern" appearance on my machine (tested .NET Framework 4 & 4.5, Win 7 Enterprise 64bit) – learningcs Apr 13 '15 at 02:15
  • My project uses .NET Framework 3.5, and my SO is Win 7 Ultimate 64-bit. '-' – Kennedy Souza Apr 13 '15 at 02:19
  • 1
    Based on [this question](http://stackoverflow.com/questions/3885245/how-to-open-new-openfiledialog-automatically-in-vista-win7/3885370#3885370) that **Youngjae** linked in the comments, then your problem must have lied in .NET 3.5: _"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"_. Good to know :) – learningcs Apr 13 '15 at 03:15
-1

OpenFileDialog dlg = new OpenFileDialog();

dlg.Filter = "All Media Files|*.wav;*.aac;*.wma;*.wmv;*.avi;*.mpg;*.mpeg;*.m1v;*.mp2;*.mp3;*.mpa;*.mpe;*.m3u;*.mp4;*.mov;*.3g2;*.3gp2;*.3gp;*.3gpp;*.m4a;*.cda;*.aif;*.aifc;*.aiff;*.mid;*.midi;*.rmi;*.mkv;*.WAV;*.AAC;*.WMA;*.WMV;*.AVI;*.MPG;*.MPEG;*.M1V;*.MP2;*.MP3;*.MPA;*.MPE;*.M3U;*.MP4;*.MOV;*.3G2;*.3GP2;*.3GP;*.3GPP;*.M4A;*.CDA;*.AIF;*.AIFC;*.AIFF;*.MID;*.MIDI;*.RMI;*.MKV";

dlg.ShowDialog();
  • 1
    The question is not about to show "any" dialog, but the "modern" dialog. This seems to be answered in the already given answer. – marsh-wiggle Jan 15 '21 at 17:10