check file exist

Hi,
 How to check if file Exist (VB6) ?

Thanks
madmareAsked:
Who is Participating?
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists("C:\Test.js") Then
  MsgBox "Exists"
End If
0
 
kaliyugkaarjunCommented:
Function FileExists(FileName As String) As Boolean
    On Error GoTo ErrorHandler
    ' get the attributes and ensure that it isn't a directory
    FileExists = (GetAttr(FileName) And vbDirectory) = 0
ErrorHandler:
    ' if an error occurs, this function returns False
End Function

 OR another way

 Function FileExist(sTestFile As String) As Boolean
    Dim lSize As Long
    On Error Resume Next
    'Preset length to -1 because files can be zero bytes in length
    lSize = -1
    'Get the length of the file
    lSize = FileLen(sTestFile)
    If lSize > -1 Then
        FileExist = True
    Else
        FileExist = False
    End If
End Function
0
All Courses

From novice to tech pro — start learning today.