Mega Code Archive

 
Categories / C# / File Stream
 

File AppendAllLines Method Appends lines to a file, and then closes the file

using System; using System.IO; using System.Linq; class Program {     static string dataPath = @"c:\t.txt";     static void Main(string[] args)     {         var text = from line in File.ReadLines(dataPath)                    where (line.Contains("a"))                    select line;         File.WriteAllLines(@"C:\data.txt", text);     } }