//字符写入文件
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();
//OpenWrite对应路径
FlieStream FStream=File.OpenWrite(path);
Byte[]info=Encoding.Default.Getbytes(string);
FStream.Write(info,0,info.Length);
//StreamReader类读文件
ReadtoEnd方法读取文件所有内容
ReadLine读取第一行