private static void PrintToConsole(FileStream fileStream)
{
byte[] buf = new byte[1024];
int bytesPerLine = Console.WindowWidth / 3, curPos = 0;
for (; ; )
{
int bytesRead = fileStream.Read(buf, 0, buf.Length);
if (bytesRead == 0) break;
for (int j = 0; j < bytesRead; curPos++, j++)
{
if (curPos >= bytesPerLine)
{
Console.WriteLine();
curPos = 0;
}
Console.Write("{0:X2} ", buf[j]);
}
}
}