XML文件在写操作完成后怎么关闭
发布网友
发布时间:2022-04-21 05:04
我来回答
共1个回答
热心网友
时间:2022-06-18 03:16
public static void Write(T config, string fileName)
{
try
{
XmlSerializer myxml = new XmlSerializer(typeof(T));
using (StreamWriter writer = new StreamWriter(fileName, false, Encoding.UTF8))
{
myxml.Serialize(writer, config);
writer.Close();
}
}
catch (Exception ex)
{
throw ex;
}
}
贴一种我用的