469,612 Members | 2,644 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

DataSet.WriteXML doesn't close the file?

UJ
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.
Apr 6 '06 #1
2 2386
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.

Apr 6 '06 #2
UJ
Thanks. I also am going to try and open a filestream, do a WriteXml (
filestream ) and then forcibly close it. Hopefully that will fix the
problem.

Thanks.

"John J. Hughes II" <no@invalid.com> wrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
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.


Apr 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Wil | last post: by
1 post views Thread by Chris Kennedy | last post: by
3 posts views Thread by Joe98765 | last post: by
reply views Thread by John George | last post: by
6 posts views Thread by Steven Nagy | last post: by
3 posts views Thread by David P. Donahue | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.