我们经常把xml存放在配置文件里面,这里详细讲述xml在配置文件的写入与读取相关逻辑
写入文件:
string szRootPath = System.AppDomain.CurrentDomain.BaseDirectory;
string szPath = szRootPath + "config.xml";
string strXml = XMLSerialize(config_Request);
File.WriteAllText(szPath, strXml, Encoding.UTF8);
读取文件:
string szRootPath = System.AppDomain.CurrentDomain.BaseDirectory;
string szPath = szRootPath + "config.xml";
string strXml = File.ReadAllText(szPath);