Read from a text file one byte at a time in CSharp
Description
The following code shows how to read from a text file one byte at a time.
Example
/*from w ww . jav a2 s. c om*/
using System;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Threading;
public class MainClass
{
public static void Main()
{
using (Stream s = new FileStream("c:\\test.txt", FileMode.Open))
{
int read;
while ((read = s.ReadByte()) != -1)
{
Console.Write("{0} ", read);
}
}
}
}