Last active
February 18, 2016 01:01
-
-
Save DanielFerguson/19d36864f53a1cc6a44d to your computer and use it in GitHub Desktop.
C# Code Notes (Volume 2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SYSTEM IO - Reading from a text file (.txt) | |
// 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. Variable text is a string | |
System.Console.WriteLine("Contents of WriteText.txt = {0}", text); | |
// READ each line of the file into a string array. Each element of the array is one line of the file | |
string[] lines = System.IO.File.ReadAllLines(@"C:\Users\Public\TestFolder\WriteLines2.txt"); | |
// DISPLAY the file contents by using a foreach loop | |
System.Console.WriteLine("Contents of WriteLines2.txt = "); | |
foreach (string line in lines) | |
{ | |
// Use a tab to indent each line of the file. | |
Console.WriteLine("\t" + line); | |
} | |
// Keep the console window open in debug mode. | |
Console.WriteLine("Press any key to exit."); | |
System.Console.ReadKey(); | |
// PLANS | |
// Link Navigation / Handling (C#) | |
// XAML Link | |
// Linda |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment