Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A Friday Tip
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
A Friday Tip
Divers
Thread ID:
00633356
Message ID:
00633356
Vues:
54
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.
George

Ubi caritas et amor, deus ibi est
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform