天津机场附近免费停车:在C#中,怎么样用System.Text下的类输出中文

来源:百度文库 编辑:神马品牌网 时间:2024/05/13 20:12:20
利用StreamWriter 和StreamReader 进行文本文件操作
先写入,然后读出.要保证读出的是中文
就想windows自带的记事本

回答者:δCat 的答案我试了,出现异常"不支持GB2313编码"

写操作:
Stream log = new FileStream(@"c:\a.txt", FileMode.Create);
System.IO.StreamWriter sw = new StreamWriter(log, System.Text.Encoding.GetEncoding("GB2312"));
sw.WriteLine("你好");
sw.Flush();
sw.Close();
log.Close();

读,仿照上面就可以了

#using system;
System.Text.cout

那就GBK