1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| XElement xElement = new XElement ( new XElement ("Setting", new XAttribute("ServiceName", "Service1"), new XAttribute("ServerName", "Server1"), new XAttribute("UserName", "Administrator"), new XAttribute("PassWord", "12345"), new XAttribute("SourcePath", @".\Source") ) ); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = new UTF8Encoding(false); settings.Indent = true; XmlWriter xw = XmlWriter.Create(System.Environment.CurrentDirectory + "\\setting.xml", settings); xElement.Save(xw);
xw.Flush(); xw.Close();
|