C#按utf8调用 FileStream,保存了一些字符串数组,然后怎么读回数组呢
string[]str={"热菜","凉菜","酒类","饮料","面食"};FileStreamfs=newFileStream("c:\\a.txt",FileMod...
string[] str = { "热菜", "凉菜", "酒类", "饮料", "面食" };
FileStream fs = new FileStream("c:\\a.txt", FileMode.Create, FileAccess.ReadWrite, FileShare.None);
for (int i = 0; i < str.Length; i++)
{
byte[] buf = Encoding.UTF8.GetBytes(str[i]);
fs.Write(buf, 0, buf.Length);
}
fs.Close(); 展开
FileStream fs = new FileStream("c:\\a.txt", FileMode.Create, FileAccess.ReadWrite, FileShare.None);
for (int i = 0; i < str.Length; i++)
{
byte[] buf = Encoding.UTF8.GetBytes(str[i]);
fs.Write(buf, 0, buf.Length);
}
fs.Close(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询