D
darrel
We're having an odd problem with our home grown CMS once in a great while,
an XML file will become corrupt...either missing, or only half-written.
We think something is happening when two people happen to hit the 'write
XML' function at exactly the same time and both process vie to write the
file first.
As such, we need to fix that. William in this forum gave me a nice example:
My question, since we really can't figure out how to test this issue, is
what will happen if I do lock the file and two process do want to write the
file. Will they queue up?
Other question...do I need to 'release' the file when done? My XML writing
function simple ends with:
objXMLWriter.WriteEndElement() 'close menuItems node
objXMLWriter.Flush()
objXMLWriter.Close()
Is there anything else I need to do to release the file for the next process
to write to it?
-Darrel
an XML file will become corrupt...either missing, or only half-written.
We think something is happening when two people happen to hit the 'write
XML' function at exactly the same time and both process vie to write the
file first.
As such, we need to fix that. William in this forum gave me a nice example:
Additionally, I believe you can lock (for writing by anyone else until you
close the file) the xml file you are writing to by using the
IO.FileShare.Read property in the sample code below
Dim fs As New System.IO.FileStream("YourXmlFile.xml", IO.FileMode.Open,
IO.FileAccess.Write, IO.FileShare.Read)
Dim xmltw As New System.Xml.XmlTextWriter(fs,
System.Text.Encoding.Default)
xmltw.WriteString("Your xml text")
My question, since we really can't figure out how to test this issue, is
what will happen if I do lock the file and two process do want to write the
file. Will they queue up?
Other question...do I need to 'release' the file when done? My XML writing
function simple ends with:
objXMLWriter.WriteEndElement() 'close menuItems node
objXMLWriter.Flush()
objXMLWriter.Close()
Is there anything else I need to do to release the file for the next process
to write to it?
-Darrel