开发者

How can I create a Save As screen in WPF?

开发者 https://www.devze.com 2023-01-04 13:46 出处:网络
I want to create a Save开发者_JAVA技巧 As screen as it is in Windows. How can I do that in a WPF application?Microsoft.Win32.SaveFileDialog is what you need. Here\'s the code snippet from MSDN;

I want to create a Save开发者_JAVA技巧 As screen as it is in Windows. How can I do that in a WPF application?


Microsoft.Win32.SaveFileDialog is what you need. Here's the code snippet from 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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号