SetAttr vbarchive

mbar

Registered User.
Local time
Today, 16:52
Joined
Nov 4, 2010
Messages
20
Hi- I'm using a function to find all files/folders in a specific directory, then copy each one to a specific destination folder. I'm going to use this on a weekly basis to backup files on a computer. I would like to use the vbarchive in GetAttr/SetAttr so I only need to copy these if they have changed since last backup. I don't, however, know how to do this and google searches don't seem to help. Can anyone help me?

Something like:

If GetAttr(strFile) And vbArchive = 32 then
filecopy xxxx, xxxx
else
rs.movenext


As I understand it, a value of 32 indicates that the file has been modified since it was last backuped up (i.e. since the file attribute was "reset"). How do I "reset" the file attributes to clear the vbArchive?? I've read some google searches and the only thing I could find was the files were set to vbnormal however I'm concerned that this will erase program files that are vbReadOnly or VbHidden.

Can someone help??
 
It doesn't make sense to me to set the attributes of the source files to store information about the status of the destination. Like, lets say you do a successful backup and set the attributes of the source files. Then someone deletes a file from the backup. In this case the attributes of the source indicating that the file was successfully backed up are wrong.

I think to do a proper backup, and only backup what's out of date or missing, you need to read the source AND the destination files, and compare for existence, and last modified date/time.

Also, what happens if you legitimately delete a source file? How is that deleted from the backup?
 
If you want to compare differences in files then you need to check the file's MD5 Checksum. Unfortunately there's no native VBA method for this but you should be able to leverage other libraries. Scour the net for "MD5 of a file + VBA".
 
Mark- Your idea is a good one however I think the vbarchive is there just for this reason. The other problem is that some files change the modified date simply when it is opened. I don't know this for a fact but have read this.

I would check for vbarchive of 32 (i.e. the file is ready for backup) OR the desination file doesn't exist. In either case, it would copy to the backup. The problem still remains on how to clear the vbarchive attribute when I've completed the backup.

If the source file is deleted, then I simple check for existence for the source file when looking at each destination file. If the source file doesn't exist, I can create the option to delete. I'm not concerned with this however.
 
you could check the file date and file size, and just copy ones that changed. these are intrinsic vba statements. the only issue is that for very large files, (eg a movie iso file, the file size exceeds a max long (which is about 2Gb).

without checking, if there is a GetAttr, there may well be a matching SetAttr. (which it looks like there is!)
 

Users who are viewing this thread

Back
Top Bottom