Connecting Tech Pros Worldwide Help | Site Map

relikangus relikangus is offline

Newbie

Visitor Messages

Showing Visitor Messages 1 to 1 of 1
  1. leo6300
    Hello! I saw your post on how to save the content of a textbox to a .txt file. Maybe you can help me. I have a textbox, textBox1, and a button, Save. When you push Save it should save the content of textBox1 to a .txt file. I copied the code, but I received some errors:
    <<'System.IO.FileMode' does not contain a definition for 'OpenORCreate'>>
    and
    <<'System.IO.StreamWriter' does not contain a definition for 'close' and no extension method 'close' accepting a first argument of type 'System.IO.StreamWriter' could be found (are you missing a using directive or an assembly reference?)>>
    The code looks like this:
    private void button1_Click(object sender, EventArgs e)
    {
    String theData = textBox1.Text;

    FileStream aFile = new FileStream("myTextFile.txt", FileMode.OpenORCreate);
    StreamWriter sw = new StreamWriter(aFile);
    sw.WriteLine(theData);
    sw.close();
    }

Statistics

Total Posts
Visitor Messages
General Information
  • Last Activity: 1 Week Ago
  • Join Date: Nov 1 '09