File pointer move and read binary file in CSharp

Description

The following code shows how to file pointer move and read binary file.

Example


using System;//from   ww  w. j a  v  a  2s. c om
using System.IO;
using System.Text;

class Class1{
  static void Main(string[] args)  {
         byte[] byData = new byte[100];
         char[] charData = new Char[100];

         FileStream aFile = new FileStream("practice.txt",FileMode.Open);
         aFile.Seek(55,SeekOrigin.Begin);
         aFile.Read(byData,0,100);

         Decoder d = Encoding.UTF8.GetDecoder();
         d.GetChars(byData, 0, byData.Length, charData, 0);

         Console.WriteLine(charData);
         return;
  }
}




















Home »
  C# Tutorial »
    IO »




File Attribute
File Security
Directory Attribute
Directory Recursive
Binary File
Text Field
Buffered IO
Create Copy Delete Move
CSV
Drive
File System Watcher
Isolated Storage
MemoryStream
Serialize
Zip