Saturday, June 20, 2009

Detect a file and folder exists on VB6

To find out if a file or folder does not exist or is exists in the VB6 programming, we can use a simple way as below:

  • Make a first module with the new name "mdlfileexists" or it's up to you.
  • Then paste the code below on the new module.

    Public Function FileExists (strPath As String) As Integer
    Dim lngRetVal As Long
    On Error Resume Next
    lngRetVal = Len(Dir$(strPath))
    If Err Or lngRetVal = 0 Then
    FileExists = False
    FileExists = True
    End if
    End Function
strPath = Filename or folder

No comments:

Post a Comment