dragon caos

dragon caos

  • NA
  • 1
  • 0

Saveing and opening

May 29 2006 2:28 AM

i need some help

when i open a saved file all the words are mixed to gether.

i am useing 1textbox,2richtextboxs,2buttons,1 savefiledialog and 1 openfiledialog

heres what i am useing
     
      Save
  
     private void button1_Click(object sender, EventArgs e)
    {
        string fname = "";
        if (fname == "")
        {
            saveFileDialog1.Filter = "Text Files|*.txt";
            DialogResult result = saveFileDialog1.ShowDialog();
            if (result == DialogResult.Cancel)
            {
                return;
            }
            fname = saveFileDialog1.FileName;
            StreamWriter s = new StreamWriter(fname);
            s.WriteLine(textBox1.Text);
            s.WriteLine(richTextBox1.Text);
            s.WriteLine(richTextBox2.Text);
            s.Flush();
            s.Close();
        }
    }

    Open

   private void button2_Click(object sender, EventArgs e)
 {
        openFileDialog1.Multiselect = false;
        openFileDialog1.Filter = "Text Files|*.txt|All files (*.*)|*.*";
        openFileDialog1.ShowDialog();
        if (File.Exists(openFileDialog1.FileName))
        {
            fname = openFileDialog1.FileName;
            StreamReader sr = new StreamReader(fname);
            textBox1.Text = sr.ReadToEnd();
            richTextBox1.Text = sr.ReadToEnd();
            richTextBox2.Text = sr.ReadToEnd();
            //dirty = false;
            sr.Close();
        }
    }

any help would be appreciated ^_^


Answers (1)