using System.IO; using (StreamReader reader = File.ReadAllText(path)) { //now your file will be closed correctly, // without having to call .close() }