I have never tried to get the WriteXml function to close the stream so I
don't know if there is a way of doing it but this is how I handle writing to
XML. You can ignore the Xceed part and just use anything that opens a
stream.
private void WriteToFile(Xceed.FileSystem.AbstractFile sentFile)
{
using (System.IO.Stream stream = sentFile.OpenWrite(true))
{
XML.XmlWriterSettings settings = new System.Xml.XmlWriterSettings();
settings.Indent = true;
settings.OmitXmlDeclaration = false;
XML.XmlWriter xw = XML.XmlWriter.Create(stream, settings);
xw.WriteStartDocument();
xw.WriteStartElement("root");
this.WriteData(xw);
xw.WriteEndElement();
xw.WriteEndDocument();
xw.Close();
stream.Close();
}
}
"UJ" <fr**@nowhere.com> wrote in message
news:O4****************@TK2MSFTNGP02.phx.gbl...
It appears when you do a DataSet.WriteXml ( <filename>, <writemode> ) it
doesn't close the file immediately.
Is that true ? The reason I think that is I have two programs that are
going to be access the same XML file and when one writes to it the other
can't seem to read it.
I've also tried running in the debugger and stopping the program on the
line after the file is written, go to the next line and then attempting to
open the file. I can't until I close the debugger.
Any suggestions?
TIA - Jeff.