生成ANSI的文本文档的问题
StreamWriter sw = new StreamWriter(weatherpath, false, Encoding.GetEncoding("GB2312"));
try
{
if (File.Exists(weather_path))
{
File.Delete(weather_path);
}
sw = File.CreateText(weather_path);
sw.Write(weather_text);
sw.Flush();
}
catch
{
//MessageBox.Show(ex.Message);
}
finally
{
sw.Close();
}
}
想生成编码为ANSI的文本文档,但生成后文档是空的,请问高手为什么,怎么能够解决?