예제 #1
0
 public static void ReadFileFromTextOurReader(string path)
 {
     using (OurReader or = new OurReader(path))
     {
         Console.WriteLine(or.Read());
     }
 }
        public static string ReadFromFile()
        {
            OurReader ourReader = new OurReader(FilePath);
            string    text      = ourReader.Read();

            ourReader.Dispose();
            return(text);
        }
        static void Main(string[] args)
        {
            CreateFolder();
            CreateFile();
            //MANUAL DISPOSE (.Dispose())
            AppendTextInFile("Hello spring!");
            AppendTextInFile("We are already done with C#");

            Console.WriteLine(ReadFromFile());

            //DISPOSE WITH USING, calls Dispose in the background
            using (OurReader reader = new OurReader(FilePath))
            {
                Console.WriteLine(reader.Read());
            }
            Console.ReadLine();
        }