DirExist

Tests for the existence of a directory.

Syntax:

DirExist(pathname)

Parameters:

(s) pathname complete drive and path.

Returns:

(i) @TRUE if the directory exists; @FALSE if it doesn't exist or if the pathname is invalid.

 

You can use this function to determine whether a specified drive is valid by checking for the existence of the root directory on that drive. A @TRUE response indicates that it is a valid drive on the system. But it does not indicate that there is a usable disk in the drive (e.g. in a Floppy drive)

This function will accept a UNC path.

This function supports extended-length path names.

Examples:
; This example checks to see if a directory c:\wp exists. If it
; doesn't one is created.
wpdir = "c:\wp"
If !DirExist(wpdir) Then DirMake(wpdir)
DirChange(wpdir)
; This section asks the user to input a drive, and then checks its
; existence.
While @TRUE ; Loop forever, until break or exit
   DRIVE = AskLine("Run Excel", "Enter a drive letter", "", 0)
   If DRIVE == "" Then Exit
   DRIVE = StrSub(DRIVE, 1, 1)
   If DirExist("%drive%:\") Then Break
EndWhile
Message("Selected Drive", DRIVE)
See Also:

DirChange, DirMake, DirRemove, DirRename, AppExist, FileExist, DiskExist