how to work with variables in files instead of memory in c#(like pagefile)

464 Views Asked by At

I have written a program that I have to save large data in the variables. how can I use files instead of memory? like virtual memory (page file)

1

There are 1 best solutions below

1
On

You can leverage Memory Mapped Files for this. In .NET Framework this nice feature is available since version 4.0.

See Non-persisted memory-mapped files

Non-persisted files are memory-mapped files that are not associated with a file on a disk. When the last process has finished working with the file, the data is lost and the file is reclaimed by garbage collection. These files are suitable for creating shared memory for inter-process communications (IPC).