首页 > 代码库 > Using Save As Dialog in WPF

Using Save As Dialog in WPF

 1                 Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); 2                 dlg.FileName = "User.txt"; // Default file name 3                 dlg.DefaultExt = ".txt"; // Default file extension 4                 dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension 5  6                 var dir = System.IO.Path.GetDirectoryName(this.txtPlace.Text); 7                 dlg.InitialDirectory = dir; 8  9                 // Show save file dialog box10                 Nullable<bool> result = dlg.ShowDialog();11 12                 // Process save file dialog box results13                 if (result == true)14                 {15                     // Save document16                     this.txtPlace.Text = dlg.FileName;17                 }

 

Using Save As Dialog in WPF