Learning CSHARP by Example
Easy writing all text to a file
WriteAllText will create the file if it doesn't exist, otherwise overwrites it. It will also close the file.
using System; namespace PlayingAround { class ReadAll { public static void Main(string[] args) { string myText = "Line1" + Environment.NewLine + "Line2" + Environment.NewLine; System.IO.File.WriteAllText(@"C:\t2", myText); } } }