473,586 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataSet.WriteXM L doesn't close the file?

UJ
It appears when you do a DataSet.WriteXm l ( <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 2677
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(Xce ed.FileSystem.A bstractFile sentFile)
{
using (System.IO.Stre am stream = sentFile.OpenWr ite(true))
{
XML.XmlWriterSe ttings settings = new System.Xml.XmlW riterSettings() ;
settings.Indent = true;
settings.OmitXm lDeclaration = false;
XML.XmlWriter xw = XML.XmlWriter.C reate(stream, settings);

xw.WriteStartDo cument();
xw.WriteStartEl ement("root");

this.WriteData( xw);

xw.WriteEndElem ent();
xw.WriteEndDocu ment();
xw.Close();
stream.Close();
}
}

"UJ" <fr**@nowhere.c om> wrote in message
news:O4******** ********@TK2MSF TNGP02.phx.gbl. ..
It appears when you do a DataSet.WriteXm l ( <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******** **********@TK2M SFTNGP05.phx.gb l...
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(Xce ed.FileSystem.A bstractFile sentFile)
{
using (System.IO.Stre am stream = sentFile.OpenWr ite(true))
{
XML.XmlWriterSe ttings settings = new System.Xml.XmlW riterSettings() ;
settings.Indent = true;
settings.OmitXm lDeclaration = false;
XML.XmlWriter xw = XML.XmlWriter.C reate(stream, settings);

xw.WriteStartDo cument();
xw.WriteStartEl ement("root");

this.WriteData( xw);

xw.WriteEndElem ent();
xw.WriteEndDocu ment();
xw.Close();
stream.Close();
}
}

"UJ" <fr**@nowhere.c om> wrote in message
news:O4******** ********@TK2MSF TNGP02.phx.gbl. ..
It appears when you do a DataSet.WriteXm l ( <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
363
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. Basically, all of the data is stored in an Access .mdb that is read into a dataset when the application is loaded. There are some minor changes...
1
3581
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 typed dataset from an xsd schema I've created in VS.NET 2002, instantiate and populate the dataset and write it as XML using WriteXML() the generated...
1
3319
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 on filling the dataset. I have also tried creating it from the XML schema but I am having problems manipulating it. If someone could point me to...
3
10281
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 using xmltextwriter to match schema without really using the xsd at the time of writing. The file I create validates but I was wondering is...
4
2397
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 and then using the writexml(...) function saves the dataset to an xml file. I have noticed that the file does not change everytime I click the...
0
264
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? Any ideas? Thanks, I am loading the xml file with this code; Dim myFileStream As New System.IO.FileStream _ (filename,...
2
2112
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 Server 2005 solution: I would store the tablename, today's date, username, and the key column values of the soon-to-be deleted row as the composite key...
6
6525
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 follows: System.IO.StringWriter sw = new StringWriter(); ds.WriteXml(sw);
3
2046
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 application was to save the data to a file (it was XML, but the format is unimportant) that can be re-loaded into the DataSet at a later time. (The reason...
0
7836
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6606
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.