using System; using System.Windows.Forms; using System.IO; using System.Text; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { System.IO.TextWriter writeFile = new StreamWriter("c:\\textwriter.txt"); writeFile.WriteLine("csharp.net-informations.com"); writeFile.Flush(); writeFile.Close(); writeFile = null; } catch (IOException ex) { MessageBox.Show(ex.ToString()); } } } }