Question

Possible Duplicate:
byte[] array pattern search

I am trying to write a simple compression algorthm in C# and .NET 3.5 and I need to be able to search a particular file for occurrences of a certain sequence of bits. what is the fastest way of doing this?

Was it helpful?

Solution

Since the file is 8K I would start by reading all the bytes into an in memory array like this:

byte[] bytes = System.IO.File.ReadAllBytes(fileName);

There is a code sample to search in this stack overflow entry:

byte[] array pattern search

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top