|
-
July 6th, 2011, 12:13 PM
#3
Re: Incrementing values in multi threaded application
Hi Arjay
Thanks for responding. I will try the change you had recommended.
Here is how I create the XML file. For few reasons, the user might process the same file again. So I first check for the existence of the file and if it exists, I try to delete the existing XML file:
if (File.Exists(strXmlPath + "\\" + strFileName + ".xml"))
File.Delete(strXmlPath + "\\" + strFileName + ".xml");
strXmlFilename = strXmlPath + "\\" + strFileName + ".tmp";
Xmlwriter = new XmlTextWriter(strXmlFilename, Encoding.UTF8);
Xmlwriter.Formatting = Formatting.Indented;
Xmlwriter.Indentation = 5;
Xmlwriter.WriteStartDocument();
//Then all the nodes in the XML file
Xmlwriter.WriteEndDocument();
Xmlwriter.Flush();
Xmlwriter.Close();
//This is rename the .tmp file to xml file
if (File.Exists(strXmlFilename))
{
File.Move(strXmlFilename, strXmlPath + "\\" + strFileName + ".xml");
}
At times the program fails during the delete command. At times the program fails during Xmlwriter = new XmlTextWriter line.
Let me know if you would need further info on this.
Thanks
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|