1.//获取系统信息等
RegistryKey rk;
rk = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion");string s= "当前操作系统版本:"+rk.GetValue("ProductName").ToString();
Console.WriteLine(s);
string hostname = System.Net.Dns.GetHostName();
System.Net.IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(hostname);
string ip = ipEntry.AddressList[0].ToString();
string os = System.Environment.OSVersion.VersionString;
2. //delete file
string pSavedPath1 = "C:\\Users\\***\\Desktop\\ConfigFile\\DeleteTest.xml";
if (File.Exists(pSavedPath1))
{
FileInfo fi = new FileInfo(pSavedPath1);
if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
fi.Attributes = FileAttributes.Normal;
File.Delete(pSavedPath1);
}
3. //Read XML file
XmlDocument doc = new XmlDocument();
doc.Load(".....\\na.xml");
XmlElement rootElem = doc.DocumentElement;
rootElem.GetElementsByTagName("Name");
XmlNode gameName = doc.SelectSingleNode("Test");
XmlNode name = gameName.SelectSingleNode("Name");
String n = name.InnerText;
Console.WriteLine(n);