MSTestExtensions/FileAssert.cs
/// <summary>
/// Checks a file for a specific byte sequence.
/// </summary>
/// <param name="path">The path to the file to check.</param>
/// <param name="searchBytes">The byte sequence to look for.</param>
/// <returns>True if the sequence was found, or false if not.</returns>
Checks a file for a specific byte sequence.
Checks a file for a specific byte sequence .
private static bool InternalContainsBytes(string path, byte[] searchBytes)
        {
            Assert.That.FileExists(path);
            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                int idx = 0;
                int b = stream.ReadByte();
                while (idx < searchBytes.Length &&
                       b == searchBytes[idx])
                {
                    b = stream.ReadByte();
                }
                if (idx >= searchBytes.Length)
                {
                    return true;
                }
            }
            return false;
        }
private static bool InternalContainsBytes ( string path , byte [ ] searchBytes ) { Assert . That . FileExists ( path ) ; using ( var stream = new FileStream ( path , FileMode . Open , FileAccess . Read ) ) { int idx = 0 ; int b = stream . ReadByte ( ) ; while ( idx < searchBytes . Length && b == searchBytes [ idx ] ) { b = stream . ReadByte ( ) ; } if ( idx >= searchBytes . Length ) { return true ; } } return false ; }
Checks a file for a specific byte sequence.
Checks a file for a specific byte sequence .
// we found the whole string.
True if the sequence was found, or false if not.
True if the sequence was found or false if not .
path
string
The path to the file to check.
The path to the file to check .
searchBytes
byte[]
The byte sequence to look for.
The byte sequence to look for .