Open/SaveFileDialog 类及其在 WPF 表单中的使用之间的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12315908/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 05:15:06  来源:igfitidea点击:

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

c#.netwpfwinformsvisual-studio-2010

提问by Jeb

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)?

System.Windows.Forms.SaveFileDialog(在Assembly System.Windows.Forms.dll 中)和Microsoft.Win32.SaveFileDialog(在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:

我在 WPF 表单中使用 PresentationFramework.dll 版本,但目前正在重新使用表单中的一些旧代码,其中包括显示 System.Windows.Forms.dll 版本并想知道是否:

  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 issuesin windows vista?
  1. 他们的外表有细微的差别吗?
  2. 使用 System.Windows.Forms.SaveFileDialog 有任何互操作性问题吗?或者这两个都只是 win32 对话框?
  3. 这只是与使用 Microsoft.Win32.SaveFileDialog在 windows vista 中存在问题有关吗?

Thanks in advance.

提前致谢。

回答by Colin Smith

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

这是一个更好的解释(可能已过时/与更高版本的 .NET 无关):

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

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.

虽然它们本质上做同样的事情……但它们是不同的包装器……围绕 WIN32 功能。

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

但是,WPF ( Microsoft.Win32) 版本的SaveFileDialog.

How to extend WPF Open/Save Dialogs:

如何扩展 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):

如果您想要更多更新版本的“通用”文件对话框(例如 Windows 7 样式的),您可以使用“Windows API 代码包”(其中一些已被纳入 .NET 4):

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.

因此,您选择哪一个取决于您的需要....如果您不进行任何自定义,那么您可以使用 Windows.Forms 之一。

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

请注意,使用 Windows.Forms 会使您的应用程序因额外的 DLL 而膨胀一点。