I am trying to remove a specific node from a XML file called "CustomersInfo" and the node is "Customer"
I have a listbox on my form that has all the customer names in it..when the user highlights the name in the listbox that they want to remove I would like to remove this customer from the XML file...here is the code I have so far
this doesnt seem correct to me....this will not delete the node where the user hightlight's the customer they want to remove...also I am getting a error "process cannot access file because it is being used by another process"
any help would be appreciated
InkedGFX
I have a listbox on my form that has all the customer names in it..when the user highlights the name in the listbox that they want to remove I would like to remove this customer from the XML file...here is the code I have so far
string path = Application.StartupPath + "[URL="file://\\CustomerInfo\\CustomerInfo.xml"]\\CustomerInfo\\CustomerInfo.xml[/URL]"; XmlDocument doc = new XmlDocument(); XmlTextReader xmlReader = new XmlTextReader(path); doc.Load(xmlReader); XmlNodeList nodes = doc.SelectNodes("/Customer"); for (int i = nodes.Count - 1; i >= 0; i++) { nodes[i].ParentNode.RemoveChild(nodes[i]); } doc.Save(path); lstCustomers.Items.Remove(lstCustomers.SelectedItem);
this doesnt seem correct to me....this will not delete the node where the user hightlight's the customer they want to remove...also I am getting a error "process cannot access file because it is being used by another process"
any help would be appreciated
InkedGFX