用二进制写入文件
FileStream fstrm = new FileStream("D:\\test.txt",FileMode.OpenOrCreate,FileAccess.Write);
Encoding encod = Encoding.Default;
sLine = Console.ReadLine();
while(sLine!=null)
{
Byte[] bytes = encod.GetBytes(sLine);
foreach (byte bNext in bytes)
{
fstrm.WriteByte(bNext);
}
fstrm.WriteByte((Byte)10); //回车
fstrm.WriteByte((Byte)13); //换行
fstrm.Flush(); //清缓冲
}
fstrm.Close();
FileStream fstrm = new FileStream("D:\\test.txt",FileMode.OpenOrCreate,FileAccess.Write);
Encoding encod = Encoding.Default;
sLine = Console.ReadLine();
while(sLine!=null)
{
Byte[] bytes = encod.GetBytes(sLine);
foreach (byte bNext in bytes)
{
fstrm.WriteByte(bNext);
}
fstrm.WriteByte((Byte)10); //回车
fstrm.WriteByte((Byte)13); //换行
fstrm.Flush(); //清缓冲
}
fstrm.Close();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货