>Over the last few days, a couple of questions regarding the use of ADIR(), and in particular the use of it to return directories. This got me to thinking and playing around. In general, my thought was that if I used the Scripting.FileSystemObject from the Windows Script Host, in conjunction with a cursor and the APPEND BLANK and GATHER NAME < object > commands, I might be to load all sub-directories into the cursor. While it may be slower that ADIR(), OTOH, it can provide more information than that function does. After a few mis-steps, I came up with the following
LOCAL lcfolder, oFSO AS Scripting.FileSystemObject,;
> oFolder, oSubFolder, lvar,
>lcfolder = GETDIR()
>IF NOT EMPTY(lcfolder)
> CREATE CURSOR ADIRECTORY (Name M, Path M,;
> DateCreated T, DateLastModified T, DateLastAccessed T,;
> Attributes I, ParentFolder M, ShortName M,;
> ShortPath M)
> oFSO = CREATEOBJECT("Scripting.FileSystemObject")
> oFolder = oFSO.GetFolder(lcfolder)
> FOR EACH oSubFolder IN oFolder.SubFolders
> * You must access each of the desired
> * members of the object for this to work
> FOR lni = 1 TO FCOUNT()
> lvar = EVALUATE('oSubFolder.' + FIELD(lni))
> NEXT
> APPEND BLANK
> GATHER NAME oSubFolder MEMO
> NEXT
>ENDIF
Note that the size property of the folder has been omitted. This is because of the amount of time it takes to calculate the size of the folder.
Hey George my friend,
This is more than good to be a Friday tip :) I only want to notify a check for catalog folders (namely 'System Volume Information') would be good. FSO tries to check its subfolders too and crashes. I add :
if oFolder.Name # 'System Volume Information'
Update: Didn't see your other post before.
Cetin