Skip to content

Instantly share code, notes, and snippets.

@bymyslf
Created January 9, 2020 08:55
Show Gist options
  • Save bymyslf/cdaef4e98c06223a3bf9775e5e6bda95 to your computer and use it in GitHub Desktop.
Save bymyslf/cdaef4e98c06223a3bf9775e5e6bda95 to your computer and use it in GitHub Desktop.
Compare streams
public static class StreamAssert
{
public static bool AreEquivalent<T>(T left, T right)
where T : Stream
{
int file1byte;
int file2byte;
if (left == right)
{
return true;
}
if (left.Length != right.Length)
{
return false;
}
do
{
file1byte = left.ReadByte();
file2byte = right.ReadByte();
}
while ((file1byte == file2byte) && (file1byte != -1));
return ((file1byte - file2byte) == 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment