Re: Search through a (large) binary file.
- From: rossum <rossum48@xxxxxxxxxxxx>
- Date: Fri, 11 Sep 2009 18:57:19 +0100
On Thu, 10 Sep 2009 16:43:16 +0200, "Michelle"
<michelle@xxxxxxxxxxxxxxx> wrote:
I need some help to search through a (sometimes large) binary file.This is essentially a string searching problem. Google for the
I'd like to search within this binary file for a pattern containing a
particular hex value (e.g. FF56131A1B087B15610800151E).
When the pattern is found, i need to know the (start) offset, because then I'd
like to read the 4 previous bytes (need the hex values).
I suppose that i need to read the file in blocks (500 kb or 1 mb) because
it's a large file.
I 'am a rookie using C#, so if possible please share a piece of code.
Thanks in advance,
Michelle
"Rabin-Karp Algorithm", the "Knuth-Morris-Pratt Algorithm" and the
"Boyer-Moore Algorithm". If there is more than one possible pattern
to search for then Rabin-Karp is the best as it can search for
multiple patterns in a single pass. If there is only a single pattern
to match then use one of the other two as they will be faster at
finding a single target.
Google will find example C# code for all three algorithms.
rossum
.
- Follow-Ups:
- Re: Search through a (large) binary file.
- From: Michelle
- Re: Search through a (large) binary file.
- References:
- Search through a (large) binary file.
- From: Michelle
- Search through a (large) binary file.
- Prev by Date: Re: IEnumerable Null
- Next by Date: Re: private and internal
- Previous by thread: Re: Search through a (large) binary file.
- Next by thread: Re: Search through a (large) binary file.
- Index(es):
Relevant Pages
|