Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 6
    Please, have look at MemoryMappedFile msdn.microsoft.com/en-us/library/… Commented May 29, 2017 at 18:30
  • 1
    "keeping it purely in RAM would make sense" - Why? Have you profiled your application and determined, that this is a bottleneck? Commented May 29, 2017 at 21:12
  • @IInspectable It's actually not so much about speed as it is about noise - the human ear suffices to determine that the hard disk thrashing and the cooling fan spinning up, are the 'bottlenecks' for that. (You need not remind me that everyone should be on SSD by now.) Commented May 30, 2017 at 0:22
  • 1
    If you specify FILE_ATTRIBUTE_TEMPORARY when creating the file, that serves as a strong hint to the file system not to bother writing it to disk. I don't know the best way to do that in C# though. Commented May 30, 2017 at 0:34
  • @HarryJohnston: that's covered here. If only FileOptions had a Temporary = 256 member, you could do this without P/Invoking to CreateFile, but in their wisdom the designers chose not to make this option available. (If you try to fudge it in, the FileStream constructor will complain.) Commented May 30, 2017 at 11:10