110,546
社区成员
发帖
与我相关
我的任务
分享
byte[] 字节1;
char[] 字符1;
try
{
FileStream 写入文件 = new FileStream("温度.txt", FileMode.Create);
字符1 = "My pink half of the drainpipe.".ToCharArray();
字节1 = new byte[字符1.Length];
Encoder 编码1 = Encoding.UTF8.GetEncoder();
编码1.GetBytes(字符1, 0, 字符1.Length, 字节1, 0, true);
写入文件.Seek(0, SeekOrigin.Begin);
写入文件.Write(字节1, 0, 字节1.Length);
}
catch (IOException ex)
{
Console.WriteLine("IO异常已被抛出!");
Console.WriteLine(ex.ToString());
Console.ReadKey();
return;
}