A few days ago we were talking about it :) First catch it returns .t. if you say :
directory('a:\')
even if there were no disc in. Of course checking device being ready is your problem and every drive has a root dir.
Next it doesn't have a way to determine when directory exists but hidden or system. ie: on a w9x system we know there is windows\sysbckup dir :
? directory('c:\windows\sysbckup') returns .F.
? adir(arrFolder,'c:\windows\sysbckup','DHS') returns 1 correctly.
IMHO only a .t. value from directory() would make sense when something other than root is queried. IOW I'd never trust and use it.
In other cases I would do a adir() and check if 5th parameter has a D in it :
lparameters tcDirToCheck
local array arrCheck[1]
local lnFound
lnFound = adir(arrCheck,tcDirToCheck,'DHS')
for ix = 1 to lnFound
if at('D',arrCheck[ix,5])>0
return .t.
endif
endfor
return .f.
And as a suplementer this would check for drive being ready :
Lparameters tcDriveName
oFS = CREATEOBJECT('Scripting.FileSystemObject')
For each oDrv in oFS.Drives
If oDrv.DriveLetter = upper(tcDriveName)
Return oDrv.IsReady
Endif
Endfor
Return .F.
Cetin
>Cetin ,thanks for your reply.
>
>Do you know in what circumstances NOT to use Directory() ?
>
>Regards,
>
>Gerard
>
>
>
>
>>>Hi.
>>>Is there a folder(0 function similar to the File() function which will return a True or false depending on the existence of a folder.
>>>(As far as I can tell, File() does not test for the occurence of Folders .
>>>
>>>i.e Is there a Folder('C:\MyHome\Myfolder') function which will return a .T. or .F.
>>>
>>>Regards,
>>>
>>>Gerard
>>Gerard,
>>There is directory(). But be aware like file() it's not reliable always. Adir() is more reliable.
>>Cetin