CSharp examples for File IO:Text File
Log Data to a File
using System;//from w w w .j a va2s . c om using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; class MainClass { static void Main(string[] args) { List<string> myList = new List<string>(); myList.Add("Log entry 1"); myList.Add("Log entry 2"); myList.Add("Log entry 3"); myList.Add("Error entry 1"); myList.Add("Error entry 2"); myList.Add("Error entry 3"); File.WriteAllLines("all_entries.log", myList); File.WriteAllLines("only_errors.log",myList.Where(e => e.StartsWith("Error"))); } }