StreamReader sr = new StreamReader(Directory.GetCurrentDirectory() + "\\test.txt") string line; while ((line = sr.ReadLine()) != null) { Console.WriteLine(line); }
写操作
string ss = "one , two , three " + "\n" + "four , fire ,sex \n seven ,eight , nine , ten"; string path = Directory.GetCurrentDirectory() + "//test.txt"; FileStream fs = new FileStream(path,FileMode.Create); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(ss); sw.Flush();