Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A Friday Tip
Message
De
15/03/2002 11:07:13
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00633356
Message ID:
00633448
Vues:
20
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform