VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

File/Directory/Drive Exists (Updated)

Jan Nawara  (3 Submissions)   Files/File Controls/Input/Output   Visual Basic 3.0   Beginner   Wed 3rd February 2021

This code returns a true/false if a specified drive/directory/pathname exists.
This is a small, fast routine.

Inputs
A string containing a pathname must be passed. If checking for a directory you must also set the second optional argument to True.

Assumes
'To check if a specific drive letter exists, use strings for the PathName argument that look like this (the strings themselves should not include quotation marks): ' '"c:" '"c:\" ' 'Eg. DriveStat= File_Exists("c:\") '(NOTE: The backslash is optional.) ' 'To check if a specific directory exists, use strings for the PathName argument that look like this (the strings themselves should not include quotation marks). ALSO, you must use True for the second optional argument, otherwise the function will not work on all directories.: ' '"c:\temp\" '"c:\windows\" ' 'Eg. DirStat = File_Exists("c:\temp", True) ' 'To check if a specific file exists, use strings for the PathName argument that look like this (the strings themselves should not include quotation marks): ' '"c:\temp\somefile.exe" '"c:\windows\notepad.exe" ' 'Eg. FileStat = File_Exists("c:\windows\win.ini")

Returns
True if the pathname and/or file exists. Otherwise it returns false.

API Declarations

Rate File/Directory/Drive Exists (Updated) (4(4 Vote))
File/Directory/Drive Exists (Updated).bas

File/Directory/Drive Exists (Updated) Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters