473,394 Members | 1,748 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,394 software developers and data experts.

Moving XML file not deleting original

I am using an XmlDocument to save some data. Periodically I add new data
and save the XmlDocument to a file:

Me.fXmlDoc.Save(Me.fFilename)

When I have added all the data I need, I want to move the file to a new
location which I do by saving the file to the new location, and then
deleting the old one:

Me.fXmlDoc.Save(newFilePath)
File.Delete(Me.fFilename)
Me.fFilename = newFilePath

However I often end up with two copies of the file, one in each location.
I suspect that what is happening is that the last few saves have not
actually made it to the disk by the time I do the Delete, and the file
gets recreated later.

Originally I was moving the original file:

Me.fXmlDoc.Save(Me.fFilename)
File.Move(Me.fFilename, newFilepath)
Me.fFilename = newFilePath

This gives the same problem, and the file in the original location
contains more data, the one in the new location is missing the last few
entries.

Is there a way to flush the data to disk, or is there a better way to do
this?

Thanks

John
Feb 15 '07 #1
0 1751

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked...
6
by: Don | last post by:
I'm having problems working with a streamwriter object. After closing the streamwriter and setting it to Nothing, I try to delete the file it was writing to, but I always get the following error...
3
by: DHarry | last post by:
How can I clear a text file without deleting and creating a new (empty) file?
2
by: fuzzybr80 | last post by:
I am using MySQL 5.0 with a number of innodb tables whose ibdata files are growing quite quickly and filling up the /var partition (file is /var/mysql/ibdata1). Earlier on I followed instructions...
7
by: Dale Sampson | last post by:
As you can tell, I am new to VS.net. I have a VB project with a defined data source pointing to a table in a ..mdb file.-- The associated fields are displayed in textboxes using the...
4
by: =?Utf-8?B?R1Q=?= | last post by:
I have a Form which has a great number of events. I thought I would organize the project by moving some of the code into multiple '.cs' files (since the Form.cs was getting huge). When I move them,...
6
by: FrankB | last post by:
Hello, after setting another image to the picture box it is not possible to delete the last shown file via File.Delete ( sFilename). Path of image file is correct. Error message box says: file...
5
by: =?Utf-8?B?YmVlamF5?= | last post by:
Whilst attempting to delete files in a folder all I get is a double up of the original file without any deletion; I now have at least 9 copies of the original file!!! Please can someone help? --...
36
by: Don | last post by:
I wrote an app that alerts a user who attempts to open a file that the file is currently in use. It works fine except when the file is opened by Notepad. If a text file is opened, most computers...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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...

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.