I have see this term branded around but I don't really understand how you open a file in memory.
I have the files written to disk in a temp location but this needs cleaning when a certain form closes and I can't do it when it's open. It's a must that this folder gets emptied. I was wondering if I opened files in memory instead whether it would make a difference?
To open a memory file, use the mmioOpen function with the szFilename parameter set to NULL and the MMIO_READWRITE flag set in the dwOpenFlags parameter.
No, it doesn't load the entire file into memory. "Opens a file" returns a handle to you allowing you to read from or write to a file.
The distinguishing characteristic of memory files is that they exist solely in memory, occupying their own memory space separate from the data and index caches. Memory files satisfy the need for the creation and manipulation of temporary data or index files that are always memory resident and never touch disk.
MemoryStream inMemoryCopy = new MemoryStream(); using (FileStream fs = File.OpenRead(path)) { fs.CopyTo(inMemoryCopy); } // Now you can delete the file at 'path' and still have an in memory copy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With