Hi,
I am creating an application where i am reading an xml,Adding some nodes and then saving it.
While saving i am getting following error.
"The process cannot access the file '"C:\p401573\myxml.xml"' because it is being used by another process."
My code is as follows
Dim xmldoc As New XmlDocument
xmldoc.Load("C:\p401573\myxml.xml")
'ConfigurationManager.AppSettings("Path") + "
Dim nlist As XmlNodeList = xmldoc.GetElementsByTagName("UserSettings")
Dim elem As XmlElement = xmldoc.CreateElement("", "User", "")
elem.SetAttribute("group", cbxUserProfile.SelectedItem)
elem.SetAttribute("Rights", "N")
nlist.Item(0).AppendChild(elem)
xmldoc.Save("C:\p401573\myxml.xml")
On last line of code when i am saving xml document back to the file above error comes.Some times this piece of code is working
myxml.xml file code
="1.0"="utf-8"
<UserSettings>
<User Name="vijavaib" SSOId="45699795" group="New Business" Rights="" />
<User Name="girinity" SSOId="757888" group="PHS" Rights="" />
<User Name="bandalpa" SSOId="64567788" group="LICENSING" Rights="" />
<User Name="hjdhjj" SSOId="658885858" group="PHS" Rights="" />
<User Name="vvv" SSOId="3165667" group="PHS" Rights="" />
<User Name="cxvbbb" SSOId="5614367" group="PHS" Rights="" />
<User Name="cxvbbb" SSOId="5614367" group="LICENSING" Rights="" />
<User Name="cxvbbb" SSOId="5614367" group="LTCNB" Rights="" />
<User Name="" SSOId="" group="ALL" Rights="" />
<User Name="gvbfgfd" SSOId="423556767" group="New Business" Rights="N" />
<User Name="tgytyry" SSOId="654657676" group="New Business" Rights="N" />
<User Name="yuuyuut" SSOId="546546757" group="New Business" Rights="N" />
<User Name="fhgffgjfj" SSOId="576575565" group="New Business" Rights="N" />
<User Name="hjhjghdj67658" SSOId="654776787" group="New Business" Rights="N" />
<User Name="hyjhjhgj" SSOId="677887789" group="New Business" Rights="N" />
<User Name="ttioioiuo" SSOId="787589980" group="ALL" Rights="N" />
</UserSettings>
But some times it give error.
Please Help its urgent.