使用BinaryWriter写文件
创建一个Windows控制台程序BinaryWriterDemo。其中主函数代码如下。注意添加System.IO引用。
static void Main(string[] args)
{
FileStream m_fs = new FileStream(@"c:\data.dat", FileMode.Create);
BinaryWrite m_bw = new BinaryWrite(m_fs);
for(int i =0; i <11; i++)
m_bw.Write((int)i);
m_bw.Close();
Console.WriteLine("Write to file succeed!");
}
|
|