Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Build directory structure
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Divers
Thread ID:
01417859
Message ID:
01417878
Vues:
84
I need to think about it because this is for a web application.
I also ran this code:
Procedure Getfilelist
   Lparameters lcFileSkeleton,lcAttributes,lcCursor
   If Pcount()<3 Or Vartype(lcCursor)#'C'
      lcCursor='curFiles'
   Endif 
   Do RecurseDirectories With lcFileSkeleton,lcAttributes,.F.,lcCursor
   Wait Clear
   Index On fullname Tag filename
   Index On filesize Tag filesize
   Index On filepath Tag filepath
   Go Top
*!*      Browse Nowait
Return Reccount()

****************************************
Procedure RecurseDirectories
   Lparameters lcFileSkeleton,lcAttributes,llKeepDirectory,lcCursor
   Local Array laDirectory[1,1]
   Local lnFileCount As Integer
   Local lnCounter As Integer
   Local lcCurrentPath As Varchar(200)
   If Empty(llKeepDirectory)
      llKeepDirectory = .F.
   Endif
*!*      If (!llKeepDirectory) And File('FileDirectory.dbf')
*!*         Use In Select('filedirectory')
*!*         Delete File filedirectory.Dbf
*!*      Endif
   If !llKeepDirectory
      Create Cursor (lcCursor);
         (fullpath Varchar(200),filepath Varchar(200),filename varchar(80), ext varchar(4), filesize Integer,fullname Varchar(100),  ModiDate Date, ModiTime Char(16), FileAttr Char(6))
   Endif
   If Empty(lcFileSkeleton)
      lcFileSkeleton = '*.*'
   Endif
   If Empty(lcAttributes)
      lcAttributes = 'DHS'
   Endif
   lnFileCount = Adir(laDirectory,lcFileSkeleton,lcAttributes)
   lcCurrentPath = Justpath(lcFileSkeleton)
   Wait 'Processing: '+substr(lcCurrentPath, 1, 200)+'..hang on!' Window Nowait
   If lnFileCount > 0
      For lnCounter = 1 To lnFileCount
         If !Empty(Strtran(laDirectory[lncounter,1],'.',''))
            If 'D' $ laDirectory[lncounter,5] && directory - need to recursively call!
               RecurseDirectories(Addbs(lcCurrentPath)+Addbs(Trim(laDirectory[lncounter,1]))+Justfname(lcFileSkeleton),lcAttributes,.T.,lcCursor)
            Else
               Insert Into (lcCursor) (fullpath, filepath,fullname,filename, ext, filesize,ModiDate,ModiTime,FileAttr);
                  Values (Addbs(lcCurrentPath) +  laDirectory[lncounter,1],lcCurrentPath,laDirectory[lncounter,1],Juststem(laDirectory[lncounter,1]),Justext(laDirectory[lncounter,1]),laDirectory[lncounter,2],laDirectory[lncounter,3],laDirectory[lncounter,4],laDirectory[lncounter,5])
            Endif
         Endif
      Endfor
   Endif && lnFileCount > 0
   Return && recursedirectories
Return && getfilelist
and it worked much, much faster.

>Hi Mark,
>
>that looks pretty optimized...
>
>Can you store the directory structure in a table and provide a Refresh button on the user interface to re-read the structure upon request?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform