using System;
using System.IO.MemoryMappedFiles;
class Program
{
static void Main()
{
// Create a memory-mapped file of 4 bytes
using var mmf = MemoryMappedFile.CreateNew("testmap", 4);
// Write an integer to the memory-mapped file
using (var accessor = mmf.CreateViewAccessor())
{
accessor.Write(0, 12345);
}
// Read the integer back
using (var accessor = mmf.CreateViewAccessor())
{
int value = accessor.ReadInt32(0);
Console.WriteLine(value); // Output: 12345
}
}
}
For storing resources on disk but having normal access to them