| This function will test if a file exists. Public Function DoesFileExist(ByVal Filename As String) As Boolean On Error GoTo ErrorHandler Dim FileNumber As Integer FileNumber = FreeFile 'Open the file - if it exists no error will occur and continue to next statement Open Filename For Input As #FileNumber 'Close it Close #FileNumber 'Return true if the length of the file is > 0 If Len(Dir$(Filename)) > 0 Then DoesFileExist = True Exit Function 'Return False if it doesn't Else DoesFileExist = False End If ErrorHandler: 'Close the file Close #FileNumber 'Return False DoesFileExist = False End Function To use simply call it like: If DoesFileExist(App.Path & "\FILE_NAME.FILE_EXTENSION") = True/False Then… Or: Exist = DoesFileExist(App.Path & "\FILE_NAME.FILE_EXTENSION") Etc. |
File Exists 3 |
Express News India | Freelance ecommerce web development India