private bool BytesMatch(byte[] readData, long readPos, byte[] searchData)
{
// First test that there are enough bytes before the end of readData to possibly contain
// searchData:
if (readPos + searchData.Length > readData.Length)
return false; // Not enough space to contain searchData
// Iterate over searchData's bytes, checking that each one matches the corrresponding
// byte in readData:
for (long i = 0; i < searchData.LongLength; i++)
if (readData[readPos + i] != searchData[i])
return false;
// All bytes in searchData match:
return true;
}