using System;
using System.Text;
using System.IO;

public class Program
{
   public static void Main(string[] args)
    {
        UseTextWriter();
        UseTextReader();

        UseBinaryWriter();
        UseBinaryReader();

        Console.ReadLine();
    }
   public static void UseTextWriter()
   {
       TextWriter tw = new StreamWriter(@"C:\temp\text.txt");

       tw.Write("Data Stream");
       tw.Close();
   }

   public static void UseTextReader()
   {
       TextReader tr = new StreamReader(@"C:\temp\text.txt");

       Console.WriteLine(tr.ReadLine());
       tr.Close();
   }

   public static void UseBinaryWriter()
   {
       FileStream fs = new FileStream(@"C:\temp\text.bin", FileMode.Create);
       BinaryWriter bw = new BinaryWriter(fs);
       bw.Write("Binary Data Stream");
       bw.Close();
   }

   public static void UseBinaryReader()
   {
       FileStream fs = new FileStream(@"C:\temp\text.bin", FileMode.Open);
       BinaryReader br = new BinaryReader(fs);
       Console.WriteLine(br.ReadString());
       br.Close();
   }

}

