0

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?

Community
  • 1
  • 1
RCIX
  • 38,647
  • 50
  • 150
  • 207

1 Answers1

1

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

Community
  • 1
  • 1
jjxtra
  • 20,415
  • 16
  • 100
  • 140