Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Open/SaveFileDialog classes and their use in a WPF form

Quite curious, but was just wondering if anyone knows the difference between using:

System.Windows.Forms.SaveFileDialog (in Assembly System.Windows.Forms.dll) and Microsoft.Win32.SaveFileDialog(in Assembly PresentationFramework.dll)?

I use the PresentationFramework.dll version within the WPF form, but am currently re-using some old code in the form which includes showing the System.Windows.Forms.dll version and wondering if:

  1. there is a subtle difference between their appearance?
  2. any interoperability issues with using the System.Windows.Forms.SaveFileDialog? Or are both these just win32 dialogs anyway?
  3. is this just to do with using Microsoft.Win32.SaveFileDialog has issues in windows vista?

Thanks in advance.

like image 319
Jeb Avatar asked Sep 07 '12 10:09

Jeb


People also ask

What method will display a SaveFileDialog or OpenFileDialog instance and allow the user to navigate their file system?

To display an Open or Save file dialog box, call the ShowDialog method on either the OpenFileDialog or SaveFileDialog control.

What is Open File dialog box?

OpenFileDialog component opens the Windows dialog box for browsing and selecting files. To open and read the selected files, you can use the OpenFileDialog. OpenFile method, or create an instance of the System.

What is dialog box in WPF?

Common dialog boxes As a user uses a common dialog box in one application, they don't need to learn how to use that dialog box in other applications. WPF encapsulates the open file, save file, and print common dialog boxes and exposes them as managed classes for you to use in standalone applications.

Is there a WPF child for openfiledialog and savefiledialog?

The new OpenFileDialog and SaveFileDialog I've created can only manipulate old style window handles, but existing WPF controls don't have one. That made the System.Windows.Window a good candidate for a WPF child since it seems to be the only one to have an easily accessible handle represented as an IntPtr type.

How to use a savefiledialog in a Windows Forms app?

In this article, I am going to explain how to use a SaveFileDialog in a Windows.Forms app using Visual Studio 2017. The SaveFileDialog prompts the users while saving files. This control allows the user to set a file name for a file. Then, you can use the event handling mechanism to add a custom code.

What is the use of savefiledialog in Salesforce?

The SaveFileDialog prompts the users while saving files. This control allows the user to set a file name for a file. Then, you can use the event handling mechanism to add a custom code. This writes the file that the user wants to save.

How do I use WPF custom file dialogs?

In order to use these controls, you need to follow several steps: Add the WpfCustomFileDialog project to your solution and reference it in your project. If you don't like this way, as other alternatives, you could just reference this DLL or drop the code into your own project.


1 Answers

Here's a better explanation (might be out of date/irrelevant for later versions of .NET):

http://www.thomasclaudiushuber.com/blog/2008/04/12/vistas-savefiledialog-and-openfiledialog-in-wpf/


While they essentially do the same thing...they're different wrappers...around the WIN32 functionality.

  • Does WPF have a native file dialog?

  • http://rpelepei.blogspot.co.uk/2010/01/using-open-file-dialog-window-in-wpf.html (see Why Bother Using the Win32 Version?)

However, there are a number of potential bugs in the WPF (Microsoft.Win32) version of the SaveFileDialog.

  • http://blog.kirupa.com/?p=119

  • SaveFileDialog bug in WPF

  • WPF Open FIle Dialog theme

  • http://learnwpf.com/post/2007/01/05/Why-does-the-OpenFileDialog-in-WPF-look-so-e2809c1999e2809d-and-how-can-I-fix-it.aspx

  • http://social.msdn.microsoft.com/Forums/en-SG/wpf/thread/03b4e9d8-4039-4e67-bf2d-5d41f65376cb

How to extend WPF Open/Save Dialogs:

  • http://www.codeproject.com/Articles/42008/Extend-OpenFileDialog-and-SaveFileDialog-Using-WPF

If you want more updated versions of the "Common" file dialogs (e.g. Windows 7 style ones) you can use the "Windows API Code Pack" (some of this has been rolled into .NET 4):

  • http://archive.msdn.microsoft.com/WindowsAPICodePack

So, which one you choose depends on your needs....if you aren't doing any customizations then you could get away with the Windows.Forms one.

Note using the Windows.Forms one will bloat your application a bit with an extra DLL.

like image 91
CSmith Avatar answered Oct 16 '22 07:10

CSmith