using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace fb { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { StreamWriter ws = new StreamWriter("C:\\File.txt"); //sw.Write(String.Join(Environment.NewLine, listBox1.Items)); //textbox ws.Write(String.Join(Environment.NewLine,"Name : ")); ws.WriteLine(String.Join(Environment.NewLine,textBox1.Text)); ws.WriteLine(String.Join(Environment.NewLine,"Responses are ")); //q1 ws.WriteLine(String.Join(Environment.NewLine,"For q1 : ")); if (radioButton1.Checked) { ws.Write(String.Join(Environment.NewLine,radioButton1.Text)); } else { ws.Write(String.Join(Environment.NewLine,radioButton2.Text)); } ws.WriteLine(String.Join(Environment.NewLine,"\n")); //q2 ws.WriteLine(String.Join(Environment.NewLine,"For q2")); if (radioButton3.Checked) { ws.Write(String.Join(Environment.NewLine,radioButton3.Text)); } else if (radioButton4.Checked) { ws.Write(String.Join(Environment.NewLine,radioButton4.Text)); } else { ws.Write(String.Join(Environment.NewLine,radioButton5.Text)); } ws.WriteLine(String.Join(Environment.NewLine,"\n")); //saving ws.Close(); MessageBox.Show("saved."); } } }
StreamWriter ws = File.AppendText("C:\\File.txt");
StreamWriter ws = new StreamWriter("C:\\File.txt", true);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)