473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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 2651
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wil | last post by:
I'm very new to developing in .NET and even newer to XML. The past few days have been pretty frustrating for me because I'm trying to perform a transform on data in a dataset and it's not working....
1
by: Dave | last post by:
Hi all, I've seen that many people have had this exact same problem in the past, but no-one seems to post the answer when (if) they solve it... so here we go again. If I create a strongly...
1
by: Chris Kennedy | last post by:
How do create a dataset from scratch based on an XML schema. This will not be filled by a dataadapter. It will be a dataset which I add rows to and then save as an XML file. All the example depend...
3
by: Joe98765 | last post by:
I have data coming from SQL Server and need to write out some XML. I have a schema(xsd) for this XML file. Right now I am bringing in the DataSet and writing out the elements and attributes myself...
4
by: Wes | last post by:
Hello, I have an application using an xml dataset to store app and user settings. The problem I am having is related to writexml. I have a save button on my application that updates the dataset...
0
by: John George | last post by:
I am writing the file correctly and it gives me the right xml file When I read it back, I am missing one element in the last row, it sets it to the initial value before I saved the origional file?...
2
by: Dean Slindee | last post by:
Before a delete on any table, I would like to write the contents of the soon-to-be-deleted row to that application's single "graveyard" table (alternate: or document as coded below). SQL...
6
by: Steven Nagy | last post by:
HI, This all applies to a project in the compact framework (Pocket PC). I need to convert a dataset object into XML which I will then send out via TCP. In a standard app I would do this as...
3
by: David P. Donahue | last post by:
I'm re-writing an application in C# that was originally written in Delphi 7. The heart of the application is a DataSet displayed in a DataGrid. One of the main functions of the previous...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.