1,savefiledialog control's property filter the file filter to display in the dialog box, for example, "text file (*.txt) |*.txt| All Files (*.*) |*.*" FilterIndex The index of the file filter selected in the dialog box, If you select the first item, set the 1 Restoredirectory Control dialog box to restore the current directory before closing addextension whether to automatically add the default extension checkfileexists checkpathexists
Before the dialog box returns, check to see if the specified path exists Container controls whether the user is prompted when the file is to be created. It is only applicable if the Validatenames is true. Defaultext Default Extension dereferencelinks
Whether to dereference a shortcut before returning from the dialog box filename The first file that is displayed in the dialog box or the last selected file initialdirector The initial directory of the dialog box Overwriteprompt control whether the user is prompted when overwriting the current file. Applies only if Validatenames is true ShowHelp enable the Help button title the character that will appear in the dialog box title bar validatenames Control Dialog Check whether the file name does not contain invalid characters or sequences
2, the SaveFileDialog event is as follows:
FileOK events to be processed when the user clicks on the "open" or "save" button helprequest events to be processed when the user clicks on the Help button
4, with the following example code can be implemented
private void Saveasdialogbtn_click (object sender, System.EventArgs e)
{
SaveFileDialog savefiledialog=new SaveFileDialog ();
savefiledialog.filter= text File |*.*| C # file |*.cs| all Files |*.* ";
savefiledialog.filterindex=2;
Savefiledialog.restoredirectory=true;
if (Savefiledialog.showdialog () ==dialogresult.ok)
{
if (Savefiledialog.showdialog () ==dialogresult.ok)
{
Fname=savefiledialog.filename;
File Fsaveas=new file (fName);
Isfilehavename=true; file://saved a file with a name
Fsaveas.writefile (richTextBox1.Text);
}
}
}