本文整理汇总了C#中System.Xml.XmlTextWriter.WriteWhitespace方法的典型用法代码示例。如果您正苦于以下问题:C# XmlTextWriter.WriteWhitespace方法的具体用法?C# XmlTextWriter.WriteWhitespace怎么用?C# XmlTextWriter.WriteWhitespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextWriter
的用法示例。
在下文中一共展示了XmlTextWriter.WriteWhitespace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportXMLfile
static void ImportXMLfile(int popMember)
{
string filename = "";
filename = GlobalVar.jobName + GlobalVar.popIndex.ToString() + popMember.ToString();
XmlTextWriter xml = null;
xml = new XmlTextWriter(filename, null);
xml.WriteStartDocument();
xml.WriteStartElement("Features");
xml.WriteWhitespace("\n");
for (int i = 0; i < GlobalVar.featureCount; i++)
{
xml.WriteElementString("Index", i.ToString());
xml.WriteElementString("Value", GlobalVar.features[i].ToString());
xml.WriteWhitespace("\n ");
}
xml.WriteEndElement();
xml.WriteWhitespace("\n");
xml.WriteEndDocument();
//Write the XML to file and close the writer.
xml.Flush();
xml.Close();
}
示例2: ExportXMLfile
static void ExportXMLfile(string XMLfile)
{
string filename = XMLfile;
try
{
File.Delete(XMLfile);
}
catch
{
// Console.Write(".X2." + XMLfile + ".");
}
XmlTextWriter xml = null;
xml = new XmlTextWriter(filename, null);
xml.WriteStartDocument();
xml.WriteStartElement("Features");
xml.WriteWhitespace("\n");
xml.WriteElementString("Score", GlobalVar.myScore.ToString());
xml.WriteWhitespace("\n ");
xml.WriteEndElement();
xml.WriteWhitespace("\n");
xml.WriteEndDocument();
//Write the XML to file and close the writer.
xml.Flush();
xml.Close();
}
示例3: Main
public static void Main (string[] args)
{
ArrayList problems;
Validator v = new Validator ();
Util.Verbosity = Util.DebugLevel.All;
Util.Inform ("Loaded schema.");
if (args.Length == 0) {
Util.Inform ("Reading from standard input.");
problems = v.ValidateString ("");
} else {
problems = v.Validate (args [0]);
}
if (XmlOutput) {
XmlTextWriter w = new XmlTextWriter (Console.Out);
w.WriteStartDocument ();
w.WriteStartElement (null, "Problems", null);
foreach (Problem p in problems)
{
w.WriteWhitespace ("\n");
w.WriteStartElement (null, "Problem", null);
w.WriteWhitespace ("\n");
w.WriteStartElement (null, "Test", null);
w.WriteString (p.Test);
w.WriteEndElement ();
w.WriteWhitespace ("\n");
w.WriteStartElement (null, "Title", null);
w.WriteString (p.Title);
w.WriteEndElement ();
w.WriteWhitespace ("\n");
w.WriteStartElement (null, "Description", null);
w.WriteString (p.Description);
w.WriteEndElement ();
w.WriteWhitespace ("\n");
w.WriteStartElement (null, "Detail", null);
w.WriteString (p.Detail);
w.WriteEndElement ();
w.WriteWhitespace ("\n");
w.WriteEndElement ();
w.WriteWhitespace ("\n");
}
w.WriteEndElement ();
w.WriteWhitespace ("\n");
w.WriteEndDocument ();
} else {
foreach (Problem p in problems)
{
Console.WriteLine (p.Title + " -- " + p.Description);
Console.WriteLine (p.Detail);
}
}
}
示例4: Display
public static void Display()
{
// Display the disclaimer
bool displayDisclaimer = true;
// Does a settings.xml exist?
if (File.Exists("settings.xml"))
{
try
{
// Load settings.xml and see if we already displayed and the user
// agreed to the disclaimer already
XmlDocument xml = new XmlDocument();
xml.Load("settings.xml");
XmlNode node = xml.SelectSingleNode("/settings");
displayDisclaimer = (node["disclaimer"].InnerText != "1");
}
catch
{
}
}
// Should we still display the disclaimer?
if (displayDisclaimer)
{
DialogResult result = MessageBox.Show("I will not use this program to cheat online.",
"Disclaimer", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
// The user agreed to it. Now write a settings.xml file and remember that they agreed to it.
if (result == DialogResult.OK)
{
using (XmlTextWriter writer = new XmlTextWriter("settings.xml", Encoding.ASCII))
{
writer.WriteStartDocument();
writer.WriteWhitespace("\n");
writer.WriteStartElement("settings");
writer.WriteWhitespace("\n\t");
writer.WriteElementString("disclaimer", "1");
writer.WriteWhitespace("\n");
writer.WriteEndElement();
writer.WriteEndDocument();
}
}
else
Environment.Exit(0);
}
}
示例5: CreateSiteMap
/// <summary>
/// 创建SiteMap文件
/// </summary>
/// <param name="path">路径</param>
/// <param name="fileName">文件名</param>
/// <param name="urlList">地址列表</param>
public static void CreateSiteMap(string path, string fileName, IList<OurUrl> urlList)
{
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
XmlTextWriter xmlWriter = new XmlTextWriter(path + @"/" + fileName, Encoding.UTF8);
xmlWriter.WriteStartDocument();
xmlWriter.WriteWhitespace("\n");
xmlWriter.WriteStartElement("urlset");
foreach (OurUrl url in urlList)
{
xmlWriter.WriteWhitespace("\n ");
xmlWriter.WriteStartElement("url");
xmlWriter.WriteWhitespace("\n ");
xmlWriter.WriteStartElement("loc");
xmlWriter.WriteValue(url.Loc);
xmlWriter.WriteEndElement();
xmlWriter.WriteWhitespace("\n ");
xmlWriter.WriteStartElement("lastmod");
xmlWriter.WriteValue(GetLastModString(url.LastMod));
xmlWriter.WriteEndElement();
xmlWriter.WriteWhitespace("\n ");
xmlWriter.WriteStartElement("changefreq");
xmlWriter.WriteValue(url.ChangeFreq.ToString().ToLower());
xmlWriter.WriteEndElement();
xmlWriter.WriteWhitespace("\n ");
xmlWriter.WriteStartElement("priority");
xmlWriter.WriteValue(url.Priority);
xmlWriter.WriteEndElement();
xmlWriter.WriteWhitespace("\n ");
xmlWriter.WriteEndElement();
}
xmlWriter.WriteWhitespace("\n");
xmlWriter.WriteEndElement();
xmlWriter.WriteWhitespace("\n");
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
xmlWriter.Close();
}
示例6: ExportXMLfile
static void ExportXMLfile(string XMLfile)
{
string filename = XMLfile;
try
{
File.Delete(XMLfile);
}
catch
{
Console.Write(".X7." + XMLfile + ".");
}
XmlTextWriter xml = null;
xml = new XmlTextWriter(filename, null);
xml.WriteStartDocument();
xml.WriteStartElement("Features");
xml.WriteWhitespace("\n");
for (int i = 0; i < GlobalVar.featureCount; i++)
{
xml.WriteElementString("Index", i.ToString());
xml.WriteWhitespace("\n ");
xml.WriteElementString("Value", GlobalVar.features[i].ToString());
xml.WriteWhitespace("\n ");
}
xml.WriteEndElement();
xml.WriteWhitespace("\n");
xml.WriteEndDocument();
//Write the XML to file and close the writer.
xml.Flush();
xml.Close();
}
示例7: CreateXmlFile
/// <summary>
/// 创建XML文件
/// </summary>
/// <param name="FileName"></param>
public void CreateXmlFile(string FileName)
{
XmlDocument xmldoc = new XmlDocument();
XmlNode node;
System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(FileName, null);
node = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);
xmldoc.AppendChild(node);
writer.WriteWhitespace(System.Environment.NewLine);
XmlNode root = xmldoc.CreateElement("Data");
xmldoc.AppendChild(root);
CreateNode(xmldoc, root, "Address", "127.0.0.1");
CreateNode(xmldoc, root, "Port", "8087");
try
{
xmldoc.Save(FileName);
writer.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例8: PreprocessListItems
/// <summary>
/// Idea here is to re-create the XmlTextReader Node and this accounts for 50% of the code.
/// Original code borrowed from http://www.sdltridionworld.com/community/2011_extensions/parentchangenotifier.aspx
/// Thanks for the work from Serguei Martchenko - would not be possible without his example!
/// </summary>
/// <param name="xReader"></param>
/// <param name="context"></param>
/// <returns></returns>
private XmlTextReader PreprocessListItems(XmlTextReader xReader, PipelineContext context)
{
TextWriter sWriter = new StringWriter();
XmlTextWriter xWriter = new XmlTextWriter(sWriter);
string attrName = "metadataFieldValue";
string attrValue = ""; // set this to 'fieldValue', for example, to debug and prove it is working
xReader.MoveToContent();
using(var tdse = new TDSEWrapper())
{
while (!xReader.EOF)
{
switch (xReader.NodeType)
{
case XmlNodeType.Element:
xWriter.WriteStartElement(xReader.Prefix, xReader.LocalName, xReader.NamespaceURI);
// add all attributes back -- always START with this to NOT break the GUI
xWriter.WriteAttributes(xReader, false);
try
{
// add my custom attribute
if (IsValidItem(xReader))
{
string id = xReader.GetAttribute("ID"); // URI
TcmUri uri = new TcmUri(id);
if (uri.ItemType == ItemType.Component)
{
// Get Metadata Value
// 0 seconds with no processing
// 12 seconds for 250 Components with TOM API, Component.MetadataFields...
// 12 seconds for 250 Components with Core Service
// 2 seconds for 250 Components with TOM API and GetXML (FASTEST!)
// Core Service
//attrValue = GetMetadataValue(fieldName, id);
// TDSE...Fastest with GetXML
Component comp = tdse.TDSE.GetObject(id, Tridion.ContentManager.Interop.TDSDefines.EnumOpenMode.OpenModeView) as Component;
attrValue = GetMetadataValue(comp, "article_number");
}
// add new metadata field attribute
xWriter.WriteAttributeString(attrName, attrValue);
xReader.MoveToElement();
}
}
catch (Exception ex)
{
Trace.TraceError("EXCEPTION " + ex.Message + ex.ToString() + ex.StackTrace);
}
if (xReader.IsEmptyElement)
{
xWriter.WriteEndElement();
}
break;
case XmlNodeType.EndElement:
xWriter.WriteEndElement();
break;
case XmlNodeType.CDATA:
// Copy CDATA node <![CDATA[]]>
xWriter.WriteCData(xReader.Value);
break;
case XmlNodeType.Comment:
// Copy comment node <!-- -->
xWriter.WriteComment(xReader.Value);
break;
case XmlNodeType.DocumentType:
// Copy XML documenttype
xWriter.WriteDocType(xReader.Name, null, null, null);
break;
case XmlNodeType.EntityReference:
xWriter.WriteEntityRef(xReader.Name);
break;
case XmlNodeType.ProcessingInstruction:
xWriter.WriteProcessingInstruction(xReader.Name, xReader.Value);
break;
case XmlNodeType.SignificantWhitespace:
xWriter.WriteWhitespace(xReader.Value);
break;
case XmlNodeType.Text:
xWriter.WriteString(xReader.Value);
break;
case XmlNodeType.Whitespace:
xWriter.WriteWhitespace(xReader.Value);
break;
}
//.........这里部分代码省略.........
示例9: PreprocessListItems
private XmlTextReader PreprocessListItems(XmlTextReader xReader, PipelineContext context)
{
TextWriter sWriter = new StringWriter();
XmlTextWriter xWriter = new XmlTextWriter(sWriter);
string attrName = "metadataFieldValue"; // Must be same as extension config, 'selector="@metadataFieldValue"'
string attrValue = "fieldValue"; // default here to confirm GUI DataExtender is working - will update value below
xReader.MoveToContent();
while (!xReader.EOF)
{
switch (xReader.NodeType)
{
case XmlNodeType.Element:
xWriter.WriteStartElement(xReader.Prefix, xReader.LocalName, xReader.NamespaceURI);
// add all list attributes back -- always START with this to NOT break the GUI
xWriter.WriteAttributes(xReader, false);
try
{
// add my custom attribute
if (IsValidItem(xReader))
{
string id = xReader.GetAttribute("ID"); // URI
TcmUri uri = new TcmUri(id);
if (uri.ItemType == ItemType.Component)
{
// Do Work Here....
attrValue = "your new value";
}
// add new metadata field attribute
xWriter.WriteAttributeString(attrName, attrValue);
xReader.MoveToElement();
}
}
catch (Exception ex)
{
Trace.TraceError("EXCEPTION " + ex.Message + ex.ToString() + ex.StackTrace);
}
if (xReader.IsEmptyElement)
{
xWriter.WriteEndElement();
}
break;
case XmlNodeType.EndElement:
xWriter.WriteEndElement();
break;
case XmlNodeType.CDATA:
// Copy CDATA node <![CDATA[]]>
xWriter.WriteCData(xReader.Value);
break;
case XmlNodeType.Comment:
// Copy comment node <!-- -->
xWriter.WriteComment(xReader.Value);
break;
case XmlNodeType.DocumentType:
// Copy XML documenttype
xWriter.WriteDocType(xReader.Name, null, null, null);
break;
case XmlNodeType.EntityReference:
xWriter.WriteEntityRef(xReader.Name);
break;
case XmlNodeType.ProcessingInstruction:
xWriter.WriteProcessingInstruction(xReader.Name, xReader.Value);
break;
case XmlNodeType.SignificantWhitespace:
xWriter.WriteWhitespace(xReader.Value);
break;
case XmlNodeType.Text:
xWriter.WriteString(xReader.Value);
break;
case XmlNodeType.Whitespace:
xWriter.WriteWhitespace(xReader.Value);
break;
}
xReader.Read();
};
xWriter.Flush();
xReader = new XmlTextReader(new StringReader(sWriter.ToString()));
xReader.MoveToContent();
//-> Write XML of tcm:Item out...
// This is where the attribute in the config file is matched -> selector="@metadataFieldValue"
// Trace.Write(sWriter.ToString() + Environment.NewLine);
return xReader;
}
示例10: WriteNode
// Writes the current node into the provided XmlWriter.
private void WriteNode(XmlTextWriter xtw, bool defattr) {
int d = this.NodeType == XmlNodeType.None ? -1 : this.Depth;
while (this.Read() && (d < this.Depth)) {
switch (this.NodeType) {
case XmlNodeType.Element:
xtw.WriteStartElement(this.Prefix, this.LocalName, this.NamespaceURI);
xtw.QuoteChar = this.QuoteChar;
xtw.WriteAttributes(this, defattr);
if (this.IsEmptyElement) {
xtw.WriteEndElement();
}
break;
case XmlNodeType.Text:
xtw.WriteString(this.Value);
break;
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
xtw.WriteWhitespace(this.Value);
break;
case XmlNodeType.CDATA:
xtw.WriteCData(this.Value);
break;
case XmlNodeType.EntityReference:
xtw.WriteEntityRef(this.Name);
break;
case XmlNodeType.XmlDeclaration:
case XmlNodeType.ProcessingInstruction:
xtw.WriteProcessingInstruction(this.Name, this.Value);
break;
case XmlNodeType.DocumentType:
xtw.WriteDocType(this.Name, this.GetAttribute("PUBLIC"), this.GetAttribute("SYSTEM"), this.Value);
break;
case XmlNodeType.Comment:
xtw.WriteComment(this.Value);
break;
case XmlNodeType.EndElement:
xtw.WriteFullEndElement();
break;
}
}
if (d == this.Depth && this.NodeType == XmlNodeType.EndElement) {
Read();
}
}
示例11: SaveRegions
public void SaveRegions()
{
Console.WriteLine("Saving regions...");
try
{
/*File.Delete(Application.StartupPath + "\\permissions.xml");
File.Create(Application.StartupPath + "\\permissions.xml");*/
using (var writer = new XmlTextWriter(Statics.SavePath + "\\regions.xml", Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteWhitespace("\r\n");
writer.WriteStartElement("WorldGuard");
writer.WriteWhitespace("\r\n\t");
writer.WriteStartElement("Regions");
foreach (Region region in Regions)
{
writer.WriteWhitespace("\r\n\t\t");
writer.WriteStartElement("Region");
writer.WriteWhitespace("\r\n\t\t\t");
writer.WriteElementString("Name", region.Name);
writer.WriteWhitespace("\r\n\t\t\t");
writer.WriteElementString("Members", region.Members);
writer.WriteWhitespace("\r\n\t\t\t");
writer.WriteElementString("Pos1", (int)region.Pos1.X + " " + (int)region.Pos1.Y);
writer.WriteWhitespace("\r\n\t\t\t");
writer.WriteElementString("Pos2", (int)region.Pos2.X + " " + (int)region.Pos2.Y);
writer.WriteWhitespace("\r\n\t\t");
writer.WriteEndElement();
}
writer.WriteWhitespace("\r\n\t");
writer.WriteEndElement();
writer.WriteWhitespace("\r\n");
writer.WriteEndElement();
writer.Close();
}
Console.WriteLine("Regions saved!");
}
catch (Exception ex)
{
Console.WriteLine("ERRROR! " + ex.Message + ex.StackTrace);
return;
}
}
示例12: SaveNewBaseLines
private static void SaveNewBaseLines()
{
lock (gate)
{
if (_newBaselines != null && !string.IsNullOrEmpty(_newBaseLinePath))
{
using (var writer = new XmlTextWriter(_newBaseLinePath, Encoding.UTF8))
{
writer.Formatting = Formatting.Indented;
writer.Indentation = 2;
writer.WriteStartDocument();
writer.WriteStartElement("baselines");
foreach (var baseLineName in _newBaselines.Keys.OrderBy(x => x))
{
var baseLineText = _newBaselines[baseLineName];
writer.WriteStartElement("baseline");
writer.WriteAttributeString("key", baseLineName);
writer.WriteWhitespace("\r\n");
writer.WriteString(baseLineText);
writer.WriteEndElement();
}
writer.WriteEndDocument();
}
}
}
}
示例13: btnSave_Click
private void btnSave_Click(object sender, RoutedEventArgs e) {
string path;
using(SaveFileDialog sfd = new SaveFileDialog()) {
sfd.Filter = QTUtility.TextResourcesDic["FileFilters"][1] + "|*.xml";
sfd.RestoreDirectory = true;
sfd.FileName = "Lng_QTTabBar_" + LangItems[1].Translated + ".xml";
if(DialogResult.OK != sfd.ShowDialog()) return;
path = sfd.FileName;
}
try {
using(XmlTextWriter writer = new XmlTextWriter(path, Encoding.UTF8)) {
writer.WriteStartDocument();
writer.WriteWhitespace(Environment.NewLine);
writer.WriteStartElement("root");
writer.WriteWhitespace(Environment.NewLine);
for(int i = 0; i < 3; i++) {
LangEntry entry = LangItems[i];
if(entry.Translated == "") continue;
writer.WriteWhitespace(Environment.NewLine);
writer.WriteStartElement(entry.Key);
writer.WriteWhitespace(Environment.NewLine);
writer.WriteValue(entry.Translated);
writer.WriteWhitespace(Environment.NewLine);
writer.WriteEndElement();
writer.WriteWhitespace(Environment.NewLine);
}
writer.WriteWhitespace(Environment.NewLine);
writer.WriteStartElement("Version_QTTabBar");
writer.WriteWhitespace(Environment.NewLine);
writer.WriteValue(QTUtility2.MakeVersionString());
writer.WriteWhitespace(Environment.NewLine);
writer.WriteEndElement();
writer.WriteWhitespace(Environment.NewLine);
writer.WriteWhitespace(Environment.NewLine);
writer.WriteStartElement("DateModified");
writer.WriteWhitespace(Environment.NewLine);
writer.WriteValue(DateTime.Now.ToString("MM/dd/yyyy"));
writer.WriteWhitespace(Environment.NewLine);
writer.WriteEndElement();
writer.WriteWhitespace(Environment.NewLine);
writer.WriteWhitespace(Environment.NewLine);
writer.WriteComment(" data start ");
writer.WriteWhitespace(Environment.NewLine);
RefInt r = new RefInt { i = 3 };
while(r.i < LangItems.Count) {
string key = LangItems[r.i].Key;
string line = GetStrings(key, r).StringJoin(Environment.NewLine);
writer.WriteWhitespace(Environment.NewLine);
writer.WriteStartElement(key);
writer.WriteWhitespace(Environment.NewLine);
writer.WriteValue(line);
writer.WriteWhitespace(Environment.NewLine);
writer.WriteEndElement();
writer.WriteWhitespace(Environment.NewLine);
}
writer.WriteWhitespace(Environment.NewLine);
writer.WriteComment(" data end ");
writer.WriteWhitespace(Environment.NewLine);
writer.WriteWhitespace(Environment.NewLine);
writer.WriteEndElement();
writer.WriteWhitespace(Environment.NewLine);
}
}
catch(XmlException) {
MessageBox.Show(QTUtility.TextResourcesDic["Options_Page13_Language"][10]);
}
catch(Exception exception2) {
QTUtility2.MakeErrorLog(exception2);
}
}
示例14: Format
/// <summary>
/// Produces a formatted string.
/// </summary>
/// <param name="loggingEvent">The event being logged.</param>
/// <param name="writer">The TextWriter to write the formatted event to</param>
/// <remarks>
/// <para>
/// Format the <see cref="LoggingEvent"/> and write it to the <see cref="TextWriter"/>.
/// </para>
/// <para>
/// This method creates an <see cref="XmlTextWriter"/> that writes to the
/// <paramref name="writer"/>. The <see cref="XmlTextWriter"/> is passed
/// to the <see cref="FormatXml"/> method. Subclasses should override the
/// <see cref="FormatXml"/> method rather than this method.
/// </para>
/// </remarks>
override public void Format(TextWriter writer, LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
throw new ArgumentNullException("loggingEvent");
}
// Attach the protected writer to the TextWriter passed in
m_protectCloseTextWriter.Attach(writer);
XmlTextWriter xmlWriter = new XmlTextWriter(m_protectCloseTextWriter);
xmlWriter.Formatting = Formatting.None;
xmlWriter.Namespaces = false;
// Write the event to the writer
FormatXml(xmlWriter, loggingEvent);
xmlWriter.WriteWhitespace(SystemInfo.NewLine);
// Close on xmlWriter will ensure xml is flushed
// the protected writer will ignore the actual close
xmlWriter.Close();
// detach from the writer
m_protectCloseTextWriter.Attach(null);
}
示例15: CreateXmlKeyFile
private static void CreateXmlKeyFile(string strFile, byte[] pbKeyData)
{
Debug.Assert(strFile != null);
if(strFile == null) throw new ArgumentNullException("strFile");
Debug.Assert(pbKeyData != null);
if(pbKeyData == null) throw new ArgumentNullException("pbKeyData");
XmlTextWriter xtw = new XmlTextWriter(strFile, new UTF8Encoding(false));
xtw.WriteStartDocument();
xtw.WriteWhitespace("\r\n");
xtw.WriteStartElement(RootElementName); // KeyFile
xtw.WriteWhitespace("\r\n\t");
xtw.WriteStartElement(MetaElementName); // Meta
xtw.WriteWhitespace("\r\n\t\t");
xtw.WriteStartElement(VersionElementName); // Version
xtw.WriteString("1.00");
xtw.WriteEndElement(); // End Version
xtw.WriteWhitespace("\r\n\t");
xtw.WriteEndElement(); // End Meta
xtw.WriteWhitespace("\r\n\t");
xtw.WriteStartElement(KeyElementName); // Key
xtw.WriteWhitespace("\r\n\t\t");
xtw.WriteStartElement(KeyDataElementName); // Data
xtw.WriteString(Convert.ToBase64String(pbKeyData));
xtw.WriteEndElement(); // End Data
xtw.WriteWhitespace("\r\n\t");
xtw.WriteEndElement(); // End Key
xtw.WriteWhitespace("\r\n");
xtw.WriteEndElement(); // RootElementName
xtw.WriteWhitespace("\r\n");
xtw.WriteEndDocument(); // End KeyFile
xtw.Close();
}