创建一个Windows控制台程序BinaryReaderDemo。其中主函数代码如下。注意添加System.IO引用。
static void Main(string[] args)
{
FileStream m_fs = new FileStream(@"c:\data.dat", FileMode.Open, FileAccess.Read);
BinaryReader m_br = new BinaryReader(m_fs);
for (int i = 0; i < 11; i++)
Console.WriteLine(m_br.ReadInt32());
m_br.Close();
Console.WriteLine("Read from file succeed!");
}
|