rwheeler23
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?
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();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER