Winforms Save As

Does anyone know of any articles or sites showing how to create a Save As dialog box in the form of a win. I have a button, the user clicks and serializes some data, the user than indicates where they want them to be saved using this "Save As" field.

+7
source share
3 answers

Do you mean SaveFileDialog ?

From the MSDN sample with slight modifications:

 using (SaveFileDialog dialog = new SaveFileDialog()) { dialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; dialog.FilterIndex = 2 ; dialog.RestoreDirectory = true ; if (dialog.ShowDialog() == DialogResult.OK) { // Can use dialog.FileName using (Stream stream = dialog.OpenFile()) { // Save data } } } 
+19
source

Use SaveFileDialog control / class.

+9
source

Im making a notepad application in C # i came up with this script to save a file, like try this. It will work great

  private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; saveFileDialog1.FilterIndex = 2; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { System.IO.StreamWriter file = new System.IO.StreamWriter(saveFileDialog1.FileName.ToString()); file.WriteLine(richTextBox1.Text); file.Close(); } } 
+2
source

All Articles