->文件编码
1)二进制,8位二进制编码表示一个字节;
2)ASCII编码
3)繁体字:BIG5编码;
4)大陆简体:GB2312编码;
5)Unicode:全球字符集;
6)UTF-8:互联网通用编码,Unicode简化编码;
–>文件读写方式–一次性读取/写入
File.ReadAllLines(path,UTF8);
File.WriteAllLines(path,string[] str,UTF8);
File.AppendAllText(path,str,UTF8);
->文件读写方式–文件流读写
FileStream fs = new FileStream(path,FileMode.OpenOrCreate);//初始化
string str = “absdrf”;//写入内容
byte[] byteArray = Encoding.UTF8.GetBytes(str);//写入内容转byte数组
fs.Write(byteArray,0,byteArray.Length);//写入path内
fs.Close();//关闭文件流
C#---文件读写stream/FileStream/StreamReader/StreamWriter
最新推荐文章于 2024-04-28 14:27:14 发布