Edit this page

RadSaveFileDialog

RadSaveFileDialog is a modal dialog box that allows you to specify a filename to save.

Figure 1: RadSaveFileDialog

RadSaveFileDialog

Showing the dialog

To show the dialog call its ShowDialog method. If a valid file is selected when you press OK, the DialogResult property will return True and the FileName property will be set. You can use FileName to get the name of the selected file.

Note that when the ShowDialog method is called the UI of the host application will freeze until the dialog closes.

Example 1: Show a save file dialog

RadSaveFileDialog saveFileDialog = new RadSaveFileDialog(); 
saveFileDialog.Owner = theHostWindowInstance;   
saveFileDialog.ShowDialog();
if (saveFileDialog.DialogResult == true)
{
    string selectedFileName = saveFileDialog.FileName;
}

Creating a stream for the selected file

You can open a read-write file stream for the selected file using the OpenFile method. Or alternatively you can use the FileName property and open the file manually.

Example 2: Open a file stream

RadSaveFileDialog saveFileDialog = new RadSaveFileDialog(); 
saveFileDialog.Owner = theHostWindowInstance;   
saveFileDialog.ShowDialog();
if (saveFileDialog.DialogResult == true)
{
    Stream fileStream = saveFileDialog.OpenFile();
}

Working with the selected file

You can get the path of the selected file via the FileName property (see Example 1). Note that the property is empty until the DialogResult is valid. When the dialog closes and if DialogResutl is True the property will return the corresponding file path.

The FileName property can be set manually. This will change the value displayed in the selected file autocomplete box area. Note that setting this won't change the selected item in the list with the files.

Example 3: Set the file name

RadSaveFileDialog saveFileDialog = new RadSaveFileDialog(); 
saveFileDialog.Owner = theHostWindowInstance;   
 saveFileDialog.InitialDirectory = @"C:\Program Files\Internet Explorer\";
saveFileDialog.FileName = @"C:\Program Files\Internet Explorer\filetosave.txt";
saveFileDialog.ShowDialog();

Figure 2: Setting the file name

Setting the file name

See Also