Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to check if a folder already exists?
Message
From
03/08/2000 13:29:59
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00400144
Message ID:
00400508
Views:
20
>>>>>
FILE("C:\MYFOLDER\NUL")
>>>>>should return .T. if C:\MyFolder exists and .F. otherwise.
>>
>>>>This does not work in all OS's (like NT or W2K). You can use ADIR() to check for the existance of a folder.
>>>>
>>>>IF ADIR(aTemp,"C:\MyFolder","D")=1
>>>>
>>>>then folder exists.
>>>
>>>Either a file or a folder exists; you need to check the file attributes of the file in the rsultant array.
>>>
>>
>>Isn't that what the "D" atribute check does?
>
>No, it permits files with the "D" attribute to be included; if a file matches the file name, then it will be present in the returned array - the attribute mask is for inclusion of files, not exclusion. Try the following:
>
>
cFile = SYS(2015)
>? STRTOFILE(cFile,cFile)
>? ADIR(aFile,cFile,'D')
>? aFile[1,5]
>ERASE (cFile)
>MD (cFile)
>? ADIR(aFile,cFile,'D')
>? aFile[1,5]
>RD (cFile)
>? ADIR(aFile,cFile,'D')
>? aFile[1,5]
Gothcha. I assumed that if the file was not a "D"irectory, the "D" attribute would not find it. Thanks for the clarification Ed.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Reply
Map
View

Click here to load this message in the networking platform