User Tools

Site Tools


wiki:streamreader

The StreamReader object

 using System.IO;  //Have to add this object to read files

 namespace HowToReadAndDisplayFiles
 {
    class Program
    {
        static void Main(string[] args)
        {
            LoadFile();
        }
        private static void LoadFile()
        {
            StreamReader inpFile = null;  
            // We're just creating the object,
            // it's null for now, but have to create it first
            inpFile = File.OpenText("../../info.txt");
            // Files are running from inside the Debug folder, so if our file is in the bin folder,
            // the ../../ just steps it up two levels to that directory
            Console.WriteLine(inpFile.ReadToEnd());
        }
    }
}
wiki/streamreader.txt · Last modified: 2019/06/23 02:28 by 64.57.171.66