using System.IO; string filePath = @"C:\temp\example.txt"; using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { using (StreamReader sr = new StreamReader(fs)) { string contents = sr.ReadToEnd(); Console.WriteLine(contents); } }
using System.IO; string filePath = @"C:\temp\example.txt"; using (FileStream fs = new FileStream(filePath, FileMode.Append, FileAccess.Write)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine("Hello world!"); } }The package library for the FileAccess class is the System.IO package.