|
|
The VerifyFile function was created with the intent to verify a critical file copy operation before performing work/deletions on the original. It checks that the file exists in a specific location, and that the file size in bytes is a specific number. Example Usage as a FileCopy verification: CODE FileCopy SourceFile, DestFile If Not VerifyFile(DestFile, FileLen(SourceFile)) Then Err.Raise vbObjectError, , "The FileCopy performed a corrupt or aborted copy!" End If CODE Public Function VerifyFile(sPath As String, lBytes As Long) As Boolean ' VerifyFile ' http://www.utteraccess.com/wiki/index.php/VerifyFile ' Code courtesy of UtterAccess Wiki ' Licensed under Creative Commons License ' http://creativecommons.org/licenses/by-sa/3.0/ ' ' You are free to use this code in any application, ' provided this notice is left unchanged. ' ' rev date brief descripton ' 1.0 2011-08-04 ' 'make sure it exists If Len(Nz(Dir(sPath))) = 0 Then VerifyFile = False Else 'check size in bytes If FileLen(sPath) <> lBytes Then VerifyFile = False Else VerifyFile = True End If End If End Function
|
| This page was last modified 01:01, 5 August 2011. This page has been accessed 302 times. Disclaimers |