Friday, February 10, 2012

How to clone an entry in Filezilla Server.xml (create users from c#)

XDocument doc = XDocument.Load(pathtoxml);

XElement templatenode = doc.Descendants("User").SingleOrDefault(p => p.Attribute("Name").Value == "templateuser");

XElement newnode = new XElement(templatenode);
newnode.Attribute("Name").Value = "newusername";

templatenode.AddAfterSelf(newnode);

doc.Save(pathtoxml);

Will create a clone of templateuser