Link to home
Start Free TrialLog in
Avatar of rwheeler23
rwheeler23Flag for United States of America

asked on

VS C# 2008 File Dialog

I am trying to present to the user a textbox that will contain a filename, complete with path, that is derived by providing a lookup to where you want this file to go. The textbox is called txtFileName.

I am trying to follow the example in the code provided below but even though I have included the System.Windows.Forms namespace it does not recognize saveFileDialog1 all I get is saveFileDialog and there is no Filter directive. What am I mssing?
private void btnSave_Click(object sender, EventArgs e)
         {
             saveFileDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
             saveFileDialog1.FilterIndex = 1;
             if (saveFileDialog1.ShowDialog() == DialogResult.OK)
             {
                 StreamWriter myStream = new StreamWriter(saveFileDialog1.FileName, true);
                 myStream.Write(richTextBox1.Text);
                 myStream.Close();
             }
         }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rwheeler23

ASKER

I see what you mean. I am learning as quickly as I can. Thanks for the tip I have it working now.