NewsBot
1
Hello all,
I'm new here so please bear with me.* I've been writing a program that I need to store the contents of a text box in a file.* The code is pasted here.* I'm not sure what I'm doing wrong.* (I've only been doing c# for 3 months....)
Thanks
Emyr
===== [ Code snippet ] =====
******* private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
******* {
*********** SaveFileDialog save = new SaveFileDialog();***********
*********** save.Filter = "Expression Files(*.exp)|*.exp";
*********** try
*********** {
*************** if (save.ShowDialog() == DialogResult.OK)
*************** {
******************* string y;
******************* y = textBox1.Text;
******************* //MessageBox.Show;
******************* FileStream aFile = new FileStream(save.FileName, FileMode.CreateNew);
******************* sw = new StreamWriter(save.FileName);
******************* //MessageBox.Show("File Saved");
******************* sw.WriteLine;
******************* //saveFile(save.FileName);
*************** }
*********** }
*********** catch (ArgumentException)
*********** {
*************** // Do nothing.* User canceled the operation
*********** }
*********** catch (IOException)
*********** {
*************** MessageBox.Show("There was an error in writing the file");
*********** }
More...
View All Our Microsoft Related Feeds
I'm new here so please bear with me.* I've been writing a program that I need to store the contents of a text box in a file.* The code is pasted here.* I'm not sure what I'm doing wrong.* (I've only been doing c# for 3 months....)
Thanks
Emyr
===== [ Code snippet ] =====
******* private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
******* {
*********** SaveFileDialog save = new SaveFileDialog();***********
*********** save.Filter = "Expression Files(*.exp)|*.exp";
*********** try
*********** {
*************** if (save.ShowDialog() == DialogResult.OK)
*************** {
******************* string y;
******************* y = textBox1.Text;
******************* //MessageBox.Show;
******************* FileStream aFile = new FileStream(save.FileName, FileMode.CreateNew);
******************* sw = new StreamWriter(save.FileName);
******************* //MessageBox.Show("File Saved");
******************* sw.WriteLine;
******************* //saveFile(save.FileName);
*************** }
*********** }
*********** catch (ArgumentException)
*********** {
*************** // Do nothing.* User canceled the operation
*********** }
*********** catch (IOException)
*********** {
*************** MessageBox.Show("There was an error in writing the file");
*********** }
More...
View All Our Microsoft Related Feeds