在 WPF Framework 4.5.2 中找不到 OpenfileDialog 的 Win32 程序集
Can't find Win32 assembly for OpenfileDialog in WPF Framework 4.5.2
我尝试在 .NET4.5.2 上的 WPF 项目中编写一个 Open/Save 文件对话框。
我找到了基于 Win32.OpenFileDialog.
的解决方案
我使用 Win8.1(x64),但在我的 Visual Studio 2015 社区的程序集中找不到任何 Win32 条目。
有没有我可以下载档案的地方?
我该如何以其他方式管理我的 Open/Save 对话框?
我相信它在 PresentationFramework
程序集中:
namespace Microsoft.Win32
{
//
// Summary:
// Represents a common dialog box that allows a user to specify a filename for one
// or more files to open.
public sealed class OpenFileDialog : FileDialog
{
//
// Summary:
// Initializes a new instance of the Microsoft.Win32.OpenFileDialog class.
[SecurityCritical]
public OpenFileDialog();
//
// Summary:
// Gets or sets an option indicating whether Microsoft.Win32.OpenFileDialog allows
// users to select multiple files.
//
// Returns:
// true if multiple selections are allowed; otherwise, false. The default is false.
public bool Multiselect { get; set; }
//
// Summary:
// Gets or sets a value indicating whether the read-only check box displayed by
// Microsoft.Win32.OpenFileDialog is selected.
//
// Returns:
// true if the checkbox is selected; otherwise, false. The default is false.
public bool ReadOnlyChecked { get; set; }
//
// Summary:
// Gets or sets a value indicating whether Microsoft.Win32.OpenFileDialog contains
// a read-only check box.
//
// Returns:
// true if the checkbox is displayed; otherwise, false. The default is false.
public bool ShowReadOnly { get; set; }
//
// Summary:
// Opens a read-only stream for the file that is selected by the user using Microsoft.Win32.OpenFileDialog.
//
// Returns:
// A new System.IO.Stream that contains the selected file.
//
// Exceptions:
// T:System.InvalidOperationException:
// No files were selected in the dialog.
[SecurityCritical]
public Stream OpenFile();
//
// Summary:
// Creates an array that contains one read-only stream for each file selected by
// the user using Microsoft.Win32.OpenFileDialog.
//
// Returns:
// An array of multiple new System.IO.Stream objects that contain the selected files.
//
// Exceptions:
// T:System.InvalidOperationException:
// No files were selected in the dialog.
[SecurityCritical]
public Stream[] OpenFiles();
//
// Summary:
// Resets all Microsoft.Win32.OpenFileDialog properties to their default values.
[SecurityCritical]
public override void Reset();
[SecurityCritical]
[SecurityTreatAsSafe]
protected override void CheckPermissionsToShowDialog();
}
}
如果您需要更好的 目录 选择对话框,您需要 Microsoft.WindowsAPICodePack
Nuget 包:
using Microsoft.WindowsAPICodePack.Dialogs;
using System.IO;
// ....
var browserDialog = new CommonOpenFileDialog();
browserDialog.IsFolderPicker = true;
browserDialog.Title = Title;
// ---
您需要在项目中添加对 PresentationFramework.dll
的引用
那么你可以简单地使用:
private Microsoft.Win32.SaveFileDialog saveDialog = new SaveFileDialog();
我尝试在 .NET4.5.2 上的 WPF 项目中编写一个 Open/Save 文件对话框。 我找到了基于 Win32.OpenFileDialog.
的解决方案我使用 Win8.1(x64),但在我的 Visual Studio 2015 社区的程序集中找不到任何 Win32 条目。
有没有我可以下载档案的地方? 我该如何以其他方式管理我的 Open/Save 对话框?
我相信它在 PresentationFramework
程序集中:
namespace Microsoft.Win32
{
//
// Summary:
// Represents a common dialog box that allows a user to specify a filename for one
// or more files to open.
public sealed class OpenFileDialog : FileDialog
{
//
// Summary:
// Initializes a new instance of the Microsoft.Win32.OpenFileDialog class.
[SecurityCritical]
public OpenFileDialog();
//
// Summary:
// Gets or sets an option indicating whether Microsoft.Win32.OpenFileDialog allows
// users to select multiple files.
//
// Returns:
// true if multiple selections are allowed; otherwise, false. The default is false.
public bool Multiselect { get; set; }
//
// Summary:
// Gets or sets a value indicating whether the read-only check box displayed by
// Microsoft.Win32.OpenFileDialog is selected.
//
// Returns:
// true if the checkbox is selected; otherwise, false. The default is false.
public bool ReadOnlyChecked { get; set; }
//
// Summary:
// Gets or sets a value indicating whether Microsoft.Win32.OpenFileDialog contains
// a read-only check box.
//
// Returns:
// true if the checkbox is displayed; otherwise, false. The default is false.
public bool ShowReadOnly { get; set; }
//
// Summary:
// Opens a read-only stream for the file that is selected by the user using Microsoft.Win32.OpenFileDialog.
//
// Returns:
// A new System.IO.Stream that contains the selected file.
//
// Exceptions:
// T:System.InvalidOperationException:
// No files were selected in the dialog.
[SecurityCritical]
public Stream OpenFile();
//
// Summary:
// Creates an array that contains one read-only stream for each file selected by
// the user using Microsoft.Win32.OpenFileDialog.
//
// Returns:
// An array of multiple new System.IO.Stream objects that contain the selected files.
//
// Exceptions:
// T:System.InvalidOperationException:
// No files were selected in the dialog.
[SecurityCritical]
public Stream[] OpenFiles();
//
// Summary:
// Resets all Microsoft.Win32.OpenFileDialog properties to their default values.
[SecurityCritical]
public override void Reset();
[SecurityCritical]
[SecurityTreatAsSafe]
protected override void CheckPermissionsToShowDialog();
}
}
如果您需要更好的 目录 选择对话框,您需要 Microsoft.WindowsAPICodePack
Nuget 包:
using Microsoft.WindowsAPICodePack.Dialogs;
using System.IO;
// ....
var browserDialog = new CommonOpenFileDialog();
browserDialog.IsFolderPicker = true;
browserDialog.Title = Title;
// ---
您需要在项目中添加对 PresentationFramework.dll
的引用那么你可以简单地使用:
private Microsoft.Win32.SaveFileDialog saveDialog = new SaveFileDialog();