- string text = System.IO.File.ReadAllText(@"txt文件路径");
- System.Console.WriteLine("Contents of WriteText.txt = {0}", text);
- string[] lines = System.IO.File.ReadAllLines(@" txt文件路径 ");
- System.Console.WriteLine("Contents of WriteLines2.txt = ");
- foreach (string line in lines)
- {
- Console.WriteLine("\t" + line);
- }
- Console.WriteLine("Press any key to exit.");
- System.Console.ReadKey();
复制代码 |