用到了一个XML文件,只是很简单的应用,写下来备查。
XML文件
文件名:Setting.xml
<?xml version="1.0" encoding="utf-8"?>
<SettingRoot>
<ServerIP>127.0.0.1</ServerIP>
<ServerPort>5003</ServerPort>
<ServiceType>1</ServiceType>
<ServiceMode>2</ServiceMode>
<ClientLoginInterval>3</ClientLoginInterval>
<ServerRefreshInterval>30</ServerRefreshInterval>
</SettingRoot>
读取内容:
使用XMLDocument
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(“Setting.xml”);
XmlNode xnIP = xmlDoc.SelectSingleNode("SettingRoot/ServerIP");
String strIP=xnIP.InnerText; //strIP=”127.0.0.1”
更改保存:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(“Setting.xml”);
XmlNode xnIP = xmlDoc.SelectSingleNode("SettingRoot/ServerIP");
xnIP.InnerText=”192.168.0.1”;
xmlDoc.Save(“Setting.xml”);
搞定,就这么多!!
更复杂的学习后再更新