How to Look for a binary sequence in a file [duplicate]
-
06-07-2019 - |
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?
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:
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow