If Statement (If File Exists)
could someone please have a look at this, there seems to be a problem, its not progressing pass the first ELSEIF.
I'm attempting to create a program that automatically installs DLL's & OCX files into the system32 folder.
VB Code:
Private Sub Label2_Click()
Dim FileToBeCopied As String
Dim Location As String
FileToBeCopied = Text1.Text
Location = "C:\WINDOWS\system32\"
If FileToBeCopied = "" Then
MsgBox "You Need To Select A File To Automatically Install", vbInformation, "No File Selected!"
ElseIf FileExists(Location & FileToBeCopied) Then
MsgBox "The File Has Been Detected As Already Existing", vbExclamation, "The Program Will End"
Else
On Error Resume Next 'Error Proof
FileCopy FileToBeCopied, Location 'Copy The File FILENAME, PATH
End If
End Sub
& this is what I have in the module for fileexists
VB Code:
Function FileExists(strFile As String) As Integer
Dim lSize As Long
On Error Resume Next
lSize = -1
lSize = FileLen(strFile)
If lSize = 0 Then
FileExists = 0
ElseIf lSize > 0 Then
FileExists = 1
Else
FileExists = -1
End If
End Function
any idea's...:confused: