?
Solved

Caching a binary file in memory for reading

Posted on 2005-02-24
2
Medium Priority
?
737 Views
Last Modified: 2008-01-09
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?  

Dave
0
Comment
Question by:daronow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
AvonWyss earned 1000 total points
ID: 13396504
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(...)));
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question