I have a procedure that writes an xml file to disk. When I click my button
and run it once, it replaces the xml file on disk as it should. If I click
the button a 2nd time, it appends. If I leave the app & click the button,
the file is replaced.
I've tried closing and flushing, but no joy. Dispose is not an available
method. Any thoughts?
Here is a snippet (ds is a dataset):
Dim tw As New System.IO.FileStream("filedrive:\path\name.xml",
IO.FileMode.Create)
Dim xw As New XmlTextWriter(tw, System.Text.Encoding.UTF8)
ds.WriteXml(xw, XmlWriteMode.WriteSchema)
xw.close()
Jeremy 7 3203
Hi Jeremy,
Set xw to nothing after close:
xw = Nothing
HTH,
Bernie Yaeger
"Jeremy" <je****@ninprodata.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... I have a procedure that writes an xml file to disk. When I click my
button and run it once, it replaces the xml file on disk as it should. If I
click the button a 2nd time, it appends. If I leave the app & click the button, the file is replaced.
I've tried closing and flushing, but no joy. Dispose is not an available method. Any thoughts?
Here is a snippet (ds is a dataset):
Dim tw As New System.IO.FileStream("filedrive:\path\name.xml", IO.FileMode.Create) Dim xw As New XmlTextWriter(tw, System.Text.Encoding.UTF8) ds.WriteXml(xw, XmlWriteMode.WriteSchema) xw.close()
Jeremy
Hi Jeremy,
Do you know that this is enough to write a dataset and schema to disk?
ds.WriteXml("filedrive:\path\name.xml", XmlWriteMode.WriteSchema)
Cor
* "Cor" <no*@non.com> scripsit: Do you know that this is enough to write a dataset and schema to disk?
ds.WriteXml("filedrive:\path\name.xml", XmlWriteMode.WriteSchema)
Do you always have a dataset?
--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Website Address Changed!
Herfried,
Can you explain the question something more? Do you always have a dataset?
Cor
Cor,
* "Cor" <no*@non.com> scripsit: Can you explain the question something more?
Oh, I feel sorry, I missed the 'ds' in the OP's post. I'll clean my
glasses now.
--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Cor, no, I didn't know that. The dox led me to believe that the syntax
you suggest would only write the schema. Sure is simpler.
Jeremy
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Bernie, turns out that I was not clearing my source dataset, so when I
re-filled it and looped through it again to write my output ds, the
source had duplicate records. The writexml code was working correctly
all along.
Jeremy
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: GDL |
last post by:
Hi,
I'm using a FileStream as below:
FileStream fs = new FileStream
(
filePath,
FileMode.Create,
FileAccess.Write,
FileShare.None
|
by: Muki Rapp |
last post by:
Hi!
In the example below, once the media is full, the FileSteam.WriteByte throws
an exception and the code
is designed to handle it. However, when the GC is invoked, it calls the
Finalize of...
|
by: Tom |
last post by:
I am working with the this object as oppose to the
StreamReader object becuase I need to access a file (to
find the contents) while an external application is
updating the file. When I was...
|
by: Dorsa |
last post by:
HI, Could you please tell me the error in here. I am trying to open an
XML file from a link.
Response.Clear()
Response.Expires = 0
Response.BufferOutput = False
Response.ContentType =...
|
by: Terry |
last post by:
In the code below, I open a file using filestream, copy it to a byte
array, and the write that array out to a new file. But when I check
the size of the original file and the new file, the new...
|
by: Loane Sharp |
last post by:
Hi there
I use the FileStream object to download a zip file over the internet to my
local disk. The file downloads successfully, but when I attempt to unzip it,
I'm told that the file is in use...
|
by: Nathan Sokalski |
last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
|
by: ewingate |
last post by:
The following code which is supposed to dynamically create files with
incrementing names is throwing an exception due to the inclusion of the
DateTime.Now component of the sReportSave string:
...
|
by: Bob |
last post by:
Hi,
Is there any setting that I can use to allow the same file to be open
in a filestream in append mode with one process and read in another.
I can see why concurrent appends or write modes...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |