blitzkriegz
blitzkriegz

Reputation: 9576

Efficient way to read index file in .NET

Dictionaries usually has an index and a data file. I'm writing a dictionary application as a hobby project. I'm confused about how to read the offset file in .NET. The index file is of 4-5 MB size. What is the most efficient way to fetch the offset/length value of a word.

EDIT: I need to know only how to read offset file if I have a word to search. ie how to search the index file for a word so that I can get the subsequent 8 bytes

Upvotes: 0

Views: 816

Answers (3)

plinth
plinth

Reputation: 49189

4-5 megabytes for the index? That's nothing. Read the entire thing into a byte array and with it as a MemoryStream or more appropriately, parse the entire contents into appropriate data structures for quick searching (has, b-tree, etc).

Upvotes: 2

rslite
rslite

Reputation: 84683

System.IO.BinaryReader has a ReadUInt32 method that reads an unsigned int. It also has different methods for reading binary files.

Upvotes: 0

Fabian Vilers
Fabian Vilers

Reputation: 2982

Stream.Seek(long offset, SeekOrigin origin) will be usefull to get to the offset.

Upvotes: 3

Related Questions