0

hi
i wana save the radioo button which user cheched to a file i wrote this code but it dosnt work... can anyone help to found the problem:

private void button1_Click(object sender, EventArgs e)
        {
            FileStream fs = new FileStream(Path1,FileMode.Append,FileAccess.Write);
            fs.Close();
            StreamWriter Wr = new StreamWriter(Path1);
            if (radioButton1.Checked)
            {
                Wr.Write(radioButton1.Text);
                check1++;
                result1++;
            }
            if (radioButton2.Checked)
            {
                Wr.Write(radioButton2.Text);
                check1++;
            }
            if (this.radioButton2.Checked == false)
                if (radioButton1.Checked == false)
                {
                    
                    check1 = 0;
                }

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by loliana
0
StreamWriter Wr = new StreamWriter(Path1);
Wr.AutoFlush=True;

what is the work of AutoFlush??

0

In lines 9 and 15 of your code, you are just writing the text of the radiobutton to a file. If your radiobutton1 text was "Mickey Mouse" and if it was checked, your file would contain the text "Mickey Mouse".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.