VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Simple function that looks either for a file or a folder and returns True if it exists or False if

by Baldho (7 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 4th December 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Simple function that looks either for a file or a folder and returns True if it exists or False if it doesn't.

Rate Simple function that looks either for a file or a folder and returns True if it exists or False if



    On Error Resume Next
    If File = True Then x = Dir(File_Folder)
    If File = False Then x = Dir(File_Folder, vbDirectory)
    On Error GoTo 0
    If x <> "" Then Exist = True Else Exist = False
End Function

'File_Folder is the entire path of the file or the folder you want to look for and File is either true or false. False means that the File_Folder parameter is a folder. True means it is a file.

'Here is an example of the code:

If Not Exist("C:\Security", False) then
    MkDir "C:\Security"
End If

Download this snippet    Add to My Saved Code

Simple function that looks either for a file or a folder and returns True if it exists or False if Comments

No comments have been posted about Simple function that looks either for a file or a folder and returns True if it exists or False if . Why not be the first to post a comment about Simple function that looks either for a file or a folder and returns True if it exists or False if .

Post your comment

Subject:
Message:
0/1000 characters