Saturday, August 8, 2015

OpenFileDialog and SaveFileDialog

 


 

Open file:

            OpenFileDialog opendialog = new OpenFileDialog();
            opendialog.Filter = "Text files|*.txt";
            opendialog.Title = "Import Settings";
            DialogResult result = opendialog.ShowDialog(); // Show the dialog.
            if (result == DialogResult.OK) // Test result.
            {
                //opendialog.FileName;
            }



Save File Dialog
            SaveFileDialog savedialog = new SaveFileDialog();
            savedialog.Filter = "Text files|*.txt";
            savedialog.Title = "Export Settings";
            DialogResult result = savedialog.ShowDialog(); // Show the dialog.
            if (result == DialogResult.OK) // Test result.
            {
               //savedialog.FileName;
            }