demonstrates use of the FileStream class - CSharp File IO

CSharp examples for File IO:FileStream

Description

demonstrates use of the FileStream class

Demo Code

using System;/*www .  ja  va  2 s.co m*/
using System.IO;

class Program {

      static void Main(string[] args) {
         FileStream F = new FileStream("test.dat", FileMode.OpenOrCreate,FileAccess.ReadWrite);

         for (int i = 1; i <= 20; i++) {
            F.WriteByte((byte)i);
         }

         F.Position = 0;
         for (int i = 0; i <= 20; i++) {
            Console.Write(F.ReadByte() + " ");
         }
         F.Close();
      }
}

Result


Related Tutorials