如何在WPF中创建“另存为”屏幕?

时间:2010-06-25 08:18:42

标签: wpf

我想创建一个另存为屏幕,就像在Windows中一样。 如何在WPF应用程序中执行此操作?

1 个答案:

答案 0 :(得分:1)

Microsoft.Win32.SaveFileDialog就是您所需要的。这是MSDN的代码片段;

// Configure save file dialog box
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "Document"; // Default file name
dlg.DefaultExt = ".text"; // Default file extension
dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension

// Show save file dialog box
Nullable<bool> result = dlg.ShowDialog();

// Process save file dialog box results
if (result == true)
{
    // Save document
    string filename = dlg.FileName;
}