- xFile – The filename (it copies from the application’s own directory)
- xDest – The destination directory
Declare
Declare Function GetVersion Lib "Kernel" () As Long
Declare Function GetFileVersionInfo% Lib "VER.DLL" (ByVal lpszFileName$, ByVal handle As Any, ByVal cbBuf&, ByVal lpvData$)
Code
Sub CheckFile(xFile As String, xDest As String)
On Error Resume Next
Dim retS%
Dim retD%
If Right(xDest, 1) <> "\" Then xDest = xDest + "\"
Form2.lblSource.Caption = App.Path + "\" + xFile
Form2.lblDestination.Caption = xDest + xFile
If Dir(xFile) = "" Then
FileCopy App.Path + "\" + xFile, xDest + xFile
Else
'Check version
retS% = GetFileVersionInfo(App.Path + "\" + xFile, 0&, 254, version)
retD% = GetFileVersionInfo(xDest + xFile, 0&, 254, version)
If retS% >= retD% Then
FileCopy App.Path + "\" + xFile, xDest + xFile
End If
End If
'Just wait for a sec
For i = 1 To 1000
DoEvents
Next i
End Sub
Tip Submitted By: Jeff Williams
Discover more from dotNetTips.com
Subscribe to get the latest posts sent to your email.
