Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在XML中使用制表符而不是空格缩进_C#_Xml - Fatal编程技术网

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;