// Read the file as one string.
string text = System.IO.File.ReadAllText(@"C:\Users\Public\TestFolder\WriteText.txt");
// Display the file contents to the console.
Console.WriteLine("Contents of writeText.txt = {0}", text);
string[] lines = System.IO.File.ReadAllLines(@"C:\Users\Public\TestFolder\WriteLines2.txt");
Console.WriteLine("Contents of writeLines2.txt =:");
foreach (string line in lines)
{
Console.WriteLine("\t" + line);
}
Console.ReadKey();
No comments:
Post a Comment