Prev: Re basic to vb
Next: String decoding
From: Tony Toews [MVP] on 23 May 2010 16:43 MM <kylix_is(a)yahoo.co.uk> wrote: >I use the free bincomp.exe. Here's how I call it from my VB6 front-end >app: Thanks for the suggestion however I want to contain everything within my single VB 6 exe. It uses a drag and drop deploy so I'm trying to keep things exceedingly simple. Tony -- Tony Toews, Microsoft Access MVP Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ For a convenient utility to keep your users FEs and other files updated see http://www.autofeupdater.com/ Granite Fleet Manager http://www.granitefleet.com/
From: Tony Toews [MVP] on 23 May 2010 16:51 Jason Keats <jkeats(a)melbpcDeleteThis.org.au> wrote: >I've used the following for SHA1: >http://vb.wikia.com/wiki/SHA-1.bas > >It seems to be faster than the CRC32 implementation you're using, is >less likely to produce duplicate values (if that's important) and it's >certainly more secure (only important if you're going to use it with >passwords, etc.). Ah, interesting. I'll do some timing tests. I've got a 300 Mb Access file which would be suitable for such. <smile> The concern is about unspecified and unknown oddities happening between the file server and the client PC when copying down files. Which is the primary purpose of my utility. These oddities should never happen. Of course. <smile> If the file server, network, and client PC are working just fine. And they probably will 99.99999% of the time. Tony -- Tony Toews, Microsoft Access MVP Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ For a convenient utility to keep your users FEs and other files updated see http://www.autofeupdater.com/ Granite Fleet Manager http://www.granitefleet.com/
From: Nobody on 24 May 2010 01:39 Tested routine, but slow for large files: ' Returns 0 when identical in size and contents Public Function CompareFiles(fn1 As String, fn2 As String) As Long Dim i As Long Dim fs1 As Long Dim fs2 As Long Dim f1 As Long Dim f2 As Long Dim b1 As Byte Dim b2 As Byte CompareFiles = 0 ' Assume identical On Error Resume Next fs1 = FileLen(fn1) If Err.Number <> 0 Then Err.Clear CompareFiles = 1 ' File 1 not found Exit Function End If fs2 = FileLen(fn2) If Err.Number <> 0 Then Err.Clear CompareFiles = 2 ' File 2 not found Exit Function End If If fs1 <> fs2 Then CompareFiles = 3 ' File size is not the same Exit Function End If f1 = FreeFile Open fn1 For Binary Access Read Shared As f1 If Err.Number <> 0 Then Err.Clear CompareFiles = 4 ' Error opening file 1 Exit Function End If f2 = FreeFile Open fn2 For Binary Access Read Shared As f2 If Err.Number <> 0 Then Err.Clear CompareFiles = 5 ' Error opening file 2 Close f1 Exit Function End If On Error GoTo 0 For i = 1 To fs1 Get f1, , b1 Get f2, , b2 If b1 <> b2 Then CompareFiles = 6 ' Contents don't match Debug.Print "CompareFiles: Mismatch at byte position " & Seek(f1) - 1 Exit For End If Next Close f2 Close f1 End Function
From: Tony Toews [MVP] on 24 May 2010 15:16 "Nobody" <nobody(a)nobody.com> wrote: >Tested routine, but slow for large files: One of the files to be compared will always be on a network file share. Thus I'd prefer to compute the CRC/hash once when it changes. Tony -- Tony Toews, Microsoft Access MVP Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/ For a convenient utility to keep your users FEs and other files updated see http://www.autofeupdater.com/ Granite Fleet Manager http://www.granitefleet.com/
From: Dee Earley on 25 May 2010 07:44
On 23/05/2010 04:56, Tony Toews [MVP] wrote: > Folks > > I've had a request to double check that files which my utility as > copied from the network server to the client PC has been copied > correctly. Presumably by using a CRC although it looks like I could > also use SHA or MD5.. > > Any comments on Calculating CRC32 With VB > http://www.vbaccelerator.com/home/vb/code/libraries/CRC32/article.asp > > Any better algorithms out there? If it works... :) Bear in mind that doing the calculations on the copying end means it needs to transfer the data twice, possibly showing the same or different corruption each time. You would really need something else (ideally the server) to generate the checksums that you then check against on the client. -- Dee Earley (dee.earley(a)icode.co.uk) i-Catcher Development Team iCode Systems (Replies direct to my email address will be ignored. Please reply to the group.) |