This is a lot of explanation for two lines of source code, but someday you might appreciate it!
When I want to make a backup of a file, I normally think of leaving the original in place, and making a copy to a backup location. I would think to use PB's FileCopy statement to copy the original to the backup destination. However, this simple process encountered unexpected interference from the OS (XP Pro and others)...
First, the copy's CreationTime gets set to the current date and time, and the copy will NOT have the CreationTime of the original file. (Reflex reaction would be to use the SetFileTime API call, but the OS can also interfere with that...)
Second, after the copy is deleted, and another copy is made to the same location, a feature of the OS called "file tunneling" could impose the CreationTime from the DELETED file onto your new copy. I was not able to overcome this effect with any use of the SetFileTime API call.
See discussion at: http://www.powerbasic.com/support/pb...ad.php?t=39340
HOWEVER, I found that NAME actually can be used to preserve the CreationTime, IF you reverse your thinking about the backup process!!!!
This way, when the OS preserves the CreationTime from the DELETED original and imposes it on the new copy, the result is precisely what was wanted -- both files are identical, right down to their CreationTime stamps!
So if it's important to you that your backup copy carry the same CreationTime stamp of the original, just follow the above two steps, and you're golden!
To add your comments, please go to the discussion thread:
http://www.powerbasic.com/support/pb...ad.php?t=39340
When I want to make a backup of a file, I normally think of leaving the original in place, and making a copy to a backup location. I would think to use PB's FileCopy statement to copy the original to the backup destination. However, this simple process encountered unexpected interference from the OS (XP Pro and others)...
First, the copy's CreationTime gets set to the current date and time, and the copy will NOT have the CreationTime of the original file. (Reflex reaction would be to use the SetFileTime API call, but the OS can also interfere with that...)
Second, after the copy is deleted, and another copy is made to the same location, a feature of the OS called "file tunneling" could impose the CreationTime from the DELETED file onto your new copy. I was not able to overcome this effect with any use of the SetFileTime API call.
See discussion at: http://www.powerbasic.com/support/pb...ad.php?t=39340
HOWEVER, I found that NAME actually can be used to preserve the CreationTime, IF you reverse your thinking about the backup process!!!!
Code:
Name SourceFile As DestinationFile ' << make backup FIRST, by MOVing original FileCopy DestinationFile, SourceFile ' << restore original from backup copy
So if it's important to you that your backup copy carry the same CreationTime stamp of the original, just follow the above two steps, and you're golden!
To add your comments, please go to the discussion thread:
http://www.powerbasic.com/support/pb...ad.php?t=39340
Comment