• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 743
  • Last Modified:

Caching a binary file in memory for reading

I've been using a BinaryReader to read in a file but I think it would be significantly faster to read the whole file into memory (we're talking about a file that's at most 1 MB) and then read it from memory using the BinaryReader functions such as ReadChar() and ReadSingle().  Can someone provide sample code for how this would be done?  

1 Solution
The BinaryReader should use a cache. If you want to test the performance difference, use a BinaryReader on a BufferedStream:

BinaryReader reader=new BinaryReader(new BufferedStream(new FileStream(...)));

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now