Click here to Skip to main content
15,559,642 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hi my xml file is

XML
<?xml version="1.0"?>
<Root>
  <FileName Name="RootProcess">
    <Id>727683220</Id>
    <FileName>adsf</FileName>
    <FilePath>d:\manohar\adsf.xml</FilePath>
    <Description>fsad sdfa</Description>
  </FileName>
  <FileName Name="PlantProcess">
    <Id>1362537878</Id>
    <FileName>PlantProcess</FileName>
    <FilePath>PlantProcess</FilePath>
    <Description> sdf sdf</Description>
  </FileName>
  <FileName Name="LogData">
    <Id>1362537878</Id>
    <FileName>LogData</FileName>
    <FilePath>PlantProcess</FilePath>
    <Description> sdf sdf</Description>
  </FileName>
</Root>



my code is

VB
If (IO.File.Exists(Server.MapPath("~/App_Data/XMLFile.xml"))) Then
           For Each gvrow As GridViewRow In dgvXmlPathSetting.Rows
               'Finiding checkbox control in gridview for particular row
               Dim chkdelete As CheckBox = DirectCast(gvrow.FindControl("chkdelete"), CheckBox)
               'Condition to check checkbox selected or not
               If chkdelete.Checked = True Then
                   'Getting UserId of particular row using datakey value
                   Dim lblId As Label = DirectCast(gvrow.FindControl("lblId"), Label)
                   Dim FileName As Label = DirectCast(gvrow.FindControl("lblFIleName"), Label)

                   Dim xmldoc As New XmlDocument()
                   xmldoc.Load(Server.MapPath("~/App_Data/XMLFile.xml"))
                   Dim nodes As XmlNodeList = xmldoc.SelectNodes("//Root/FileName[@Name='" & FileName.Text.Trim() & "']")
                   'Dim nodes As XmlNodeList = xmldoc.SelectNodes("/Root/FileName[@Name="" & FileName & ""]")
                   For i As Integer = nodes.Count - 1 To 0 Step -1
                       nodes(i).ParentNode.RemoveChild(nodes(i))
                   Next
                   '  reader.Close()
                   xmldoc.Save(Server.MapPath("~/App_Data/XMLFile.xml"))
               End If
           Next
           loadXmlToGridview()
       End If



in xmldoc.save error is coming

The process cannot access the file 'D:\Manohar\srsConnect\App_Data\XMLFile.xml' because it is being used by another process.

can anyone help
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900