Ich bin immer noch am Anfang mit XML-Dateien. Ich möchte Verzeichnisse mit einem XML erstellen, und ich habe diese Funktion:Importieren Sie XML und erstellen Sie Verzeichnisse C#
RunCommand eine Funktion ist, die comanda_cmd zuerst ausführen, zweite sind Strings
private void ProcesNode(XmlNode node, string parentPath, string path, string first, string second, string BuiltUnit, string item)
{
if (!node.HasChildNodes || ((node.ChildNodes.Count == 2) && (node.FirstChild is System.Xml.XmlText)))
{
//MessageBox.Show(parentPath + "/" + node.Name);
}
else
{
foreach (XmlNode child in node.ChildNodes)
{
comanda_cmd = first + "/" + parentPath + second + "/" + parentPath + "/" + node.Name;
string status = RunCommand(comanda_cmd + "/project.pj /n");
//content = "_GEN_PROJECT/" + ProjectName + "/" + BuiltUnit + "/" + item + "/" + parentPath + "/" + node.Name + " already exist";
//MessageBox.Show(content);
//check_status(status, content);
ProcesNode(child, parentPath + "/" + node.Name, path, first, second, BuiltUnit, item);
}
}
}
Und ich habe diese XML:
<unit>
<Unit1>
<src>
<i>
<test1>
<test_in1>
<test_in_out>
<t>
</t>
</test_in_out>
</test_in1>
</test1>
<test2>
<test_in2>
</test_in2>
</test2>
</i>
</src>
<doc>
<i>
<test1>
<test_in1>
<test_in_out>
<t>
</t>
</test_in_out>
</test_in1>
</test1>
<test2>
<test_in2>
</test_in2>
</test2>
</i>
</doc>
</Unit1>
<Unit2>
<src>
<i>
</i>
</src>
</Unit2>
</unit>
Ich rufe ProcesNode auf, und es erstellt die Verzeichnisse. Zum Beispiel: unit/Unit1/src/i/test1/test_in1/test_in_out aber das letzte Verzeichnis (in meinem Fall "t") wird nicht erstellt.
Wo liege ich falsch? Warum erstellt es nicht das letzte Verzeichnis?
Für die niedrigsten Tags ('') die 'if'-Bedingung' (! node.HasChildren || ...) '' '' '' wahr ', so dass Sie nicht den 'else'-Block eingeben, der die Verzeichnisse erstellt. –
Sie haben Recht! Vielen Dank Rene Vogt –