Skip to content

Instantly share code, notes, and snippets.

@scorta
Last active December 21, 2015 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scorta/6363957 to your computer and use it in GitHub Desktop.
Save scorta/6363957 to your computer and use it in GitHub Desktop.
// 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();
//In order to append an existing file, set the Boolean parameter to true, as follows:
System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt", true);
//Read from File
string allText = System.IO.Files.ReadAllText("C:\\test.txt");
//There are some way to read from file (ReadAllText, ReadAllLines,..). You should check it yourself
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment