How can i check whether a folder exist?

rainylsh

Member
hello everybody:
The system's default path is D:\, But there are some PCs have not D:\, only C:\, So I would check whether d:\ (or a folder) exist, if not I would assign a path for file outputting to.
How can i check whether a folder exist?:confused:
 

jongpau

Member
Have a play with this:
Code:
FILE-INFO:FILE-NAME = "d:/":U.
MESSAGE FILE-INFO:FULL-PATHNAME FILE-INFO:FILE-TYPE.
If the folder does not exist both full-pathname and file-type will get the unknown value (?). If it does exist you can test file-type to make sure you are looking at a folder and not a file.

HTH,

Paul
 

jongpau

Member
file-info also allows you to see whether the user has rights to read/write in the specified folder and/or file. You could even combine its use with "os-drives", which gives a list of the available harddisks in your system, so you can check each one (and checking is always a good idea; my os-drives for instance also lists some magical "F" drive that I do not have at all - it may be the memory card reader in my laptop or something). But as always, in the end it all depends on what your requirements are :)

Paul
 

dayv2005

Member
My bad the search is for if a file exist.

Try this...

/* Set the directory name in question */
FILE-INFO:FILE-NAME = "N:\temp".

/* display the attributes of "dirname" */
MESSAGE FILE-INFO:FILE-TYPE VIEW-AS ALERT-BOX.

if ? then it don't exist if DRW then it exist.
 

pokey

New Member
does a directory always return DRW as its attributes? How can you tell if a directory is read-only?
 
Top