System.IO.MemoryMappedFiles namespace

System.IO.MemoryMappedFiles namespace

The System.IO.MemoryMappedFiles namespace provides classes for using a memory-mapped file, which maps the contents of a file to an application's logical address space.

Memory-mapped files enable us to work with extremely large files because memory can be managed concurrently, and they allow complete, random access to a file without the need for seeking.

Memory mapping is also useful in sharing data between an application's threads, but also between processes running on the same system. To share data between processes, all you need to do is give your mapped view object a unique name. If this name matches that in the other process(es), then the data is automatically shared.

  FileStream file = new FileStream(@"C:\Temp\MyFile.dat", FileMode.Open);

  MemoryMappedFile mmf =   MemoryMappedFile.CreateFromFile(file);

  MemoryMappedViewAccessor accessor =    mmf.CreateViewAccessor();

-shinu

Ebook Download
View all
Learn
View all