private void simpleButton1_Click(object sender, EventArgs e)
{
Stream myStream;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "Text Files (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 1;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if (( myStream = saveFileDialog1.OpenFile()) != null)
{
StreamWriter Text = new StreamWriter(myStream);
Text.WriteLine(textBox1.Text);
Text.WriteLine(textBox1.Text.ToString());
Text.WriteLine(memoEdit1.Text);
Text.WriteLine(memoEdit1.Text.ToString());
Text.WriteLine(memoEdit1.ToString());
myStream.Close();
}
}
}
In this scenario, I tried to have 2 components to contain text namely textBox1 and memoEdit1. What I'm trying to do is that when I click this button, a dialog box appears and ask me where to save the file(Text File) and after which it creates a text file that copies the contents of my textBox1 and memoEdit1 into it. But in my case, yes it successfully created a text file but it's empty, I tried various ways to for this but I always fail. I would really appreciate your help. Thnx in advance.


Sign In
Create Account

Back to top









