J
Jagadeesh
hi ,
Am trying to read from and write to a same xml file.i have no prob when
reading the xml file.but when i write to the same file i get the following
error even after closing the reader object(which is open).
The file is being used by some other process.
---------------------------------------------------
This is what am doing in the code:
i have used the XmlTextReader and loaded the file to an XmlDocument
object and closed the Reader object. and after the processing of the
documnet, am writing to the file by passing a XmltextWriter obj to the
save() method in XmlDocument class. [more over I came to know that the
reader.close() only changes the read state to closed]
-------------------------------------------------------
Code Block here:
xdoc.Load(fs); //Loading the file
try
{fs.Close(); //Closing the file
Thread.Sleep(1000);
}
catch
{Thread.Sleep(1000);}
xmltagfinder();
XmlNode unode;
nodelist=xdoc.GetElementsByTagName(xnode.Name);
unode=nodelist[0].FirstChild;
count=nodelist.Count;i=0;
while(i!=count)
{
if(unode.ParentNode.ParentNode.Name!="LIST_ITEMS")
{
if(Convert.ToInt32(unode.InnerText)==Convert.ToInt32(id1))
{
unode.NextSibling.InnerText="";
unode.NextSibling.InnerText=name;
}
else
{
unode=nodelist.FirstChild;
}
}
i++;
xtr=null
xdoc.Save("d:/Dash2.xml"); //i also tried
xdoc.Save(fs);
}
regards
Jagadeesh
Am trying to read from and write to a same xml file.i have no prob when
reading the xml file.but when i write to the same file i get the following
error even after closing the reader object(which is open).
The file is being used by some other process.
---------------------------------------------------
This is what am doing in the code:
i have used the XmlTextReader and loaded the file to an XmlDocument
object and closed the Reader object. and after the processing of the
documnet, am writing to the file by passing a XmltextWriter obj to the
save() method in XmlDocument class. [more over I came to know that the
reader.close() only changes the read state to closed]
-------------------------------------------------------
Code Block here:
xdoc.Load(fs); //Loading the file
try
{fs.Close(); //Closing the file
Thread.Sleep(1000);
}
catch
{Thread.Sleep(1000);}
xmltagfinder();
XmlNode unode;
nodelist=xdoc.GetElementsByTagName(xnode.Name);
unode=nodelist[0].FirstChild;
count=nodelist.Count;i=0;
while(i!=count)
{
if(unode.ParentNode.ParentNode.Name!="LIST_ITEMS")
{
if(Convert.ToInt32(unode.InnerText)==Convert.ToInt32(id1))
{
unode.NextSibling.InnerText="";
unode.NextSibling.InnerText=name;
}
else
{
unode=nodelist.FirstChild;
}
}
i++;
xtr=null
xdoc.Save("d:/Dash2.xml"); //i also tried
xdoc.Save(fs);
}
regards
Jagadeesh