BinaryWriter类:MSDN,以二进制形式将基元类型写入流,并支持用特定的编码写入字符串。 static void Main(string[] args)
{
bool b = true;
BinaryWriter bw = new BinaryWriter(new FileStream(@"d:\love.txt", FileMode.Open), Encoding.UTF8);
bw.Write(b);
Console.ReadKey();
}
上面代码使用BinaryWriter类的 Write 方法编写布尔值到流为一个字节值,为什么打开文件,里面什么都没写呢?
{
bool b = true;
BinaryWriter bw = new BinaryWriter(new FileStream(@"d:\love.txt", FileMode.Open), Encoding.UTF8);
bw.Write(b);
Console.ReadKey();
}
上面代码使用BinaryWriter类的 Write 方法编写布尔值到流为一个字节值,为什么打开文件,里面什么都没写呢?
BinaryWriter bw = new BinaryWriter(new FileStream(@"d:\love.txt", FileMode.OpenOrCreate), Encoding.UTF8);
bw.Write(b);
bw.Flush();
bw.Close();
这种问题来CSDN问人挺麻烦的(浪费时间) 自己慢慢调试一下就行了(调试和写代码同样重要)
还是没有写进东西啊
bool b = true;
BinaryWriter bw = new BinaryWriter(ss, Encoding.UTF8);
bw.Write(b这个蛋疼);
bw.Close();
ss.Colse();
Console.ReadKey();
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs);
bw.Write(b);
bw.Close();
fs.Close();
bw = null;
fs = null;