Memory-Mapped Files and Random File I/O


using System;
using System.IO;
using System.IO.MemoryMappedFiles;

using System.Linq;
using System.Text;

class Program
{
    static void Main()
    {
        File.WriteAllBytes("long.bin", new byte[100]);

        using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile("long.bin"))
        using (MemoryMappedViewAccessor accessor = mmf.CreateViewAccessor())
        {
            accessor.Write(5, (byte)77);
            Console.WriteLine(accessor.ReadByte(5)); // 77
        }
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.