473,802 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.fF ilename, 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 1790

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

Similar topics

6
2863
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 fine while the file was in the project directory. When the obsolete file was removed from the project directory, my application will no longer compile. Can someone please help with this issue? Thank in advance, Tom
6
10220
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 message: "The process cannot access the file "whatever" because it is being used by another process." I've even tried opening another file using the same streamwriter object before deleting the original file, but it's no use. Something keeps...
3
15886
by: DHarry | last post by:
How can I clear a text file without deleting and creating a new (empty) file?
2
38958
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 in the docs to create a new ibdata file on a bigger partition /disk2/var/mysql/ibdata2) and set that to autoextend instead. However I would like to reclaim the disk space on /var by moving the existing ibdata1 file to /disk2/var/mysql/ibdata1....
7
27843
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 tableBindingSource. There is also an associated BindingNavigator. The table's primary key is a field called 'who'. I have a valid value for 'who' and want to set the Navigator to the record that contains this value so the fields are displayed in the associated...
4
1377
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, it seems that Visual Studio can no longer find them when I open a Button object (for example) and double click on the previously created event. On top of this, Visual Studio creates a new event that is blank. I know the program can 'see' my moved...
6
15095
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 is being used by other process. Is there a way to "free" the file? Thank you for your help.
5
1165
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? -- beejay
36
5411
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 are configured to use Notepad to open the file by default and if they are configured to use Notepad by default I want it to remain that way rather than retrieve the text into my app or force the user to use another app to read the file. I'm...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10538
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10285
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
6838
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.