0

How do I get the SaveFileDialog to pop up and redirect to a selected folder? I have tried what I can but I've only established to get the program to open the File Explorer and redirect to the folder without the SaveFileDialog working.

This is my code:

private void button9_Click(object sender, EventArgs e)
{
    Stream myStream;
    SaveFileDialog saveFileDialog1 = new SaveFileDialog();

    saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
    saveFileDialog1.FilterIndex = 2;
    saveFileDialog1.RestoreDirectory = true;

    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
    {
        if ((myStream = saveFileDialog1.OpenFile()) != null)
        {
            myStream.Close();
        }
    }
}
double-beep
  • 5,031
  • 17
  • 33
  • 41

1 Answers1

0

Just set your initial directory

For example:

        saveFileDialog1.InitialDirectory = @"C:\Users\<username>\Desktop";
Pete
  • 469
  • 7
  • 18