|
-
Oct 19th, 2008, 11:28 AM
#1
Thread Starter
PowerPoster
[RESOLVED] determine if file changed
I am trying to create a file backup, but only want to overwrite files that have changed
How can i do this without using FSO ?
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Oct 19th, 2008, 11:33 AM
#2
Re: determine if file changed
This is what the Archive attribute was for.
XXCOPY TECHNICAL BULLETIN #06 offers one explanation.
-
Oct 19th, 2008, 11:50 AM
#3
PowerPoster
Re: determine if file changed
The best way would be to generate a checksum value for each file, then check the checksum against the current file's checksum and see if they match...if not, they've changed.
Dilettante's suggestion, while the standard method, is open to outside intervention...meaning that some files might not be backed up when you run your backup code.
And regarding checksums (in case you need to ask), anything will do...CRC32 is usually what people use and more than enough, but MD5 is the best option...and there's free functions out there for calculating both :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Oct 19th, 2008, 01:13 PM
#4
Thread Starter
PowerPoster
Re: determine if file changed
Thanks guys found this little function that seems to do what i need:
Code:
Public Function FileUpToDate(sPath As String, sDest As String) As Boolean
Dim a, b, c As Variant
FileUpToDate = Len(Dir$(sPath)) > 0
If FileUpToDate = False Then Exit Function
'Already False if not exist so just exit
'Here is where I need more code to compare file Tmie/Dates
a = FileDateTime(sPath)
b = FileDateTime(sDest)
c = DateDiff("s", a, b)
If c < 0 Then FileUpToDate = False Else FileUpToDate = True
End Function
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Oct 19th, 2008, 01:50 PM
#5
PowerPoster
Re: determine if file changed
The code you found will work, and won't need you to keep any data about each file, but my suggestion's still the best :-)
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Oct 19th, 2008, 05:19 PM
#6
Re: determine if file changed
 Originally Posted by smUX
The code you found will work, and won't need you to keep any data about each file, but my suggestion's still the best :-)
LOL!
Why your suggestion's still the best while other way works and "won't need you to keep any data about each file"?
-
Oct 19th, 2008, 05:39 PM
#7
PowerPoster
Re: determine if file changed
 Originally Posted by anhn
Why your suggestion's still the best while other way works and "won't need you to keep any data about each file"? 
1) The archive bit of a file is not limited to the one program, any can change it
2) The date is not a 100% reliable way of checking which file is the newer...all it takes is a clock to be wrong somewhere and it ruins the whole thing
3) Checksum is the only 100% reliable way of checking to see if a file has changed...although the date *may* be considered reliable enough as the likelihood of it going wrong is low
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Oct 19th, 2008, 07:22 PM
#8
Re: determine if file changed
No way is 100% reliable.
Not everyone can change "the archive bit" of a file.
If everyone can change it then it is no longer 100% reliable.
If "although the date *may* be considered reliable enough as the likelihood of it going wrong is low" then why not use that?
Respect your "professinal way of using CRC" but you should not say "but my suggestion's still the best". I will never use that "best" suggestion.
-
Oct 19th, 2008, 08:10 PM
#9
PowerPoster
Re: [RESOLVED] determine if file changed
It's the best because it's the most reliable, and yes it is the closest to 100% reliable (as you said, nothing is 100% reliable, there is a chance of two CRCs being the same, but there's more chance of me winning the lottery every week without ever playing even once :-)) but it does have the overhead of having to store the CRC data for each file which may be too much of an overhead :-)
It's your choice to "never use that best suggestion", just as it's my choice to suggest it :-P
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|