Move file reading pointer in CSharp

Description

The following code shows how to move file reading pointer.

Example


using System;/* w ww  . j  a  va2s  . co  m*/
using System.IO;
using System.IO.Compression;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;

public class MainClass
{
    public static void Main()
    {
        using (Stream s = new FileStream("c:\\test.txt", FileMode.Open))
        {
            s.Seek(8, SeekOrigin.Current);
            Console.WriteLine(s.ReadByte());
            s.Seek(0, SeekOrigin.Begin);
            Console.WriteLine(s.ReadByte());
            s.Seek(-1, SeekOrigin.End);
            Console.WriteLine(s.ReadByte());
        }
    }
}




















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