using System;
using System.IO;
using System.Text;
...
public void WriteFile()
{
FileStream fs = File.Create("unnamed.dat");
Byte[] buf = Encoding.GetEncoder("gb2312").GetBytes("select * from table");
fs.Write(buf, 0, buf.Length);
fs.Close();
}
public void ReadFile()
{
FileStream fs = File.Open("unnamed.dat");
Byte[] buf = new Byte[fs.Length];
fs.Read(buf, 0, fs.Length);
string content = Encoding.GetEncoder("gb2312").GetString(buf);
...
}
大概就是这样的,你自己测试一下。