12 Jul

Save A File With SaveFileDialog Using C#

This example shows how to save a file using the SaveFileDialog dialog box. SaveFileDialog allows users to set a file name for a specific file. It is found in System.Windows.Forms namespace and it displays the standard Windows dialog box.


            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.Title = "Save";
            saveDialog.Filter = "Text Files (*.txt)|*.txt" + "|" +
                                "Image Files (*.png;*.jpg)|*.png;*.jpg" + "|" +
                                "All Files (*.*)|*.*";
            if (saveDialog.ShowDialog() == DialogResult.OK)
                string file = saveDialog.FileName;