SaveFileDialog (C#/CSharp)

This CSharp (C#) code snippet demonstrates how to let the user select a filename with the SaveFileDialog control.

private void SaveFileDialog_Example()
{
    SaveFileDialog mySaveFileDialog = new SaveFileDialog();

    // optional filter to restrict file types
    mySaveFileDialog.Filter = "CSV Files|*.csv";

    if (mySaveFileDialog.ShowDialog() == DialogResult.OK)
    {
        string selectedFileName = mySaveFileDialog.FileName;

        // do whatever you like with the selected filename
    }
}