C# 在XML中使用制表符而不是空格缩进
好的,我有一些代码,应该用来更改配置文件中的值C# 在XML中使用制表符而不是空格缩进,c#,xml,C#,Xml,好的,我有一些代码,应该用来更改配置文件中的值 string xmlFile = "KeePass.config.xml"; System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); XmlWriterSettings settings = new XmlWriterSettings(); settings.IndentChars = "\t"; se
string xmlFile = "KeePass.config.xml";
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlWriterSettings settings = new XmlWriterSettings();
settings.IndentChars = "\t";
settings.Indent = true;
xmlDoc.Load(xmlFile);
xmlDoc.SelectSingleNode("Configuration/Application/LastUsedFile").InnerText = fileName;
xmlDoc.Save(xmlFile);
问题是,它使用空格而不是制表符缩进XML文件,读取配置文件的程序需要使用制表符缩进查看XML。任何帮助都将不胜感激。您试过了吗
xmlDoc.PreserveWhitespace = true;