static void Main(string[] args)
{
//C#文件流写文件,默认追加FileMode.Append
string msg = "okffffffffffffffff";
byte[] myByte = System.Text.Encoding.UTF8.GetBytes(msg);
using (FileStream fsWrite = new FileStream(@"D:\1.txt", FileMode.Append))
{
fsWrite.Write(myByte, 0, myByte.Length);
};
//c#文件流读文件
using (FileStream fsRead = new FileStream(@"D:\1.txt", FileMode.Open))
{
int fsLen = (int)fsRead.Length;
byte[] heByte = new byte[fsLen];
int r = fsRead.Read(heByte, 0, heByte.Length);
string myStr = System.Text.Encoding.UTF8.GetString(heByte);
Console.WriteLine(myStr);
Console.ReadKey();
}
}