Reset internal position for a FileStream : FileStream : File Directory Stream C# Examples


C# Examples » File Directory Stream » FileStream »

 

Reset internal position for a FileStream









    
using  System;
using  System.IO;

public  class  MainClass
{
        public  static  int  Main(string[]  args)
        {            
        FileInfo  f  =  new  FileInfo(@"C:\test.txt");
        FileStream    s  =  f.Open(FileMode.OpenOrCreate,  FileAccess.ReadWrite,  FileShare.None);        

        for(int  i  =  0;  i  <  256;  i++)
        {
            s.WriteByte((byte)i);
        }

        //  Reset  internal  position.
        s.Position  =  0;

        for(int  i  =  0;  i  <  256;  i++)
        {
            Console.Write(s.ReadByte());    
        }
        s.Close();
        f.Delete();

                return  0;
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo File Directory Stream
» FileStream