// Read the file as one string.
System.IO.StreamReader myFile =
new System.IO.StreamReader("c:\\test.txt");
string myString = myFile.ReadToEnd();myFile.Close();// Display the file contents.
Console.WriteLine(myString);
// Suspend the screen.
Console.ReadLine();
// Compose a string that consists of three lines.
string lines = "First line.\r\nSecond line.\r\nThird line.";// Write the string to a file.
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
file.WriteLine(lines);file.Close();
System.IO.StreamReader myFile =
new System.IO.StreamReader("c:\\test.txt");
string myString = myFile.ReadToEnd();myFile.Close();// Display the file contents.
Console.WriteLine(myString);
// Suspend the screen.
Console.ReadLine();
// Compose a string that consists of three lines.
string lines = "First line.\r\nSecond line.\r\nThird line.";// Write the string to a file.
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
file.WriteLine(lines);file.Close();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货