VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



ValidateFile

by Ian Ippolito (vWorker) (14 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

Determines if a file exists
Improved version--detects hidden files too!

Inputs
filename--file to validate
Code Returns
'returns true or false

Rate ValidateFile

Function Validate_File (ByVal FileName As String) As Integer
Dim fileFile As Integer
  'attempt to open file
  fileFile = FreeFile
  On Error Resume Next
  Open FileName For Input As fileFile
  
  'check for error
  If Err Then
    Validate_File = False
  Else
    'file exists
    'close file
    Close fileFile
    Validate_File = True
  End If
End Function

Download this snippet    Add to My Saved Code

ValidateFile Comments

No comments have been posted about ValidateFile. Why not be the first to post a comment about ValidateFile.

Post your comment

Subject:
Message:
0/1000 characters