Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get file list (large amount) without ADIR()
Message
De
16/07/2001 07:13:22
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
13/07/2001 17:01:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00530511
Message ID:
00530911
Vues:
25
This message has been marked as the solution to the initial question of the thread.
>Hello !!
>
>I would like to get a list of file in a directory...
>Normally, I use the ADIR() command but in this case, there is a large amount of files (about 20000).
>So the ADIR() command fails because of the VFP system capabilities (65000 records in an array...)
>
>Which replacement to ADIR() can I use ?
>Is there a solution with API's or WSH ??
>
>(just to get the file list, then I'll put each name in a record of a dbf file..It will be easier to manage...)
>
>Thanks a lot !

Stephane,
You could use WSH. ie:
Gettree('c:\Program Files',.t.)

Function Gettree
Lparameters tcDirectory, tlFiles
*Start = seconds()
Create cursor crsFiles ;
  (FolderId i, Filename m, FileSize i, Created t, Modified t, Accessed t)
Create cursor crsFolders (Folder m, FolderId i)

oFS = CREATEOBJECT('Scripting.FileSystemObject')
oFolder = oFS.GetFolder(tcDirectory)
Insert into crsFolders ;
  (Folder , FolderId ) ;
  values ;
  (oFolder.Path, reccount('crsFolders')+1)
If tlFiles
   GetFiles(oFolder, reccount('crsFolders'))
Endif
  
tcDirectory = iif(oFolder.IsRootFolder(), ;
  substr(tcDirectory,1,len(tcDirectory)-1), tcDirectory)
=_SubFolders(oFolder, tcDirectory, tcDirectory,tlFiles)
*? seconds()-start
select crsFiles
index on FolderId tag FolderID
select Folder, Filename , FileSize , Created , Modified , Accessed ;
 from crsFolders join crsFiles on crsFolders.FolderId = crsFiles.FolderId 

Function _SubFolders
Lparameters toFolder, tcPath, tcStartPath, tlFiles
Local loSubFolders
tcPath = tcStartPath
For each oSubFolder in toFolder.Subfolders
  If oSubFolder.Name # "System Volume Information"
    Insert into crsFolders ;
      (Folder , FolderId ) ;
      values ;
      (oSubFolder.Path, reccount('crsFolders')+1)
    If tlFiles
      GetFiles(oSubFolder, reccount('crsFolders'))
    Endif
    =_SubFolders(oSubFolder, tcPath, tcPath+"\"+ oSubFolder.name, tlFiles)
  Endif
Endfor

Function GetFiles
Lparameters toFolder, tnId
For each oFile in toFolder.Files
  Insert into crsFiles ;
    (FolderId, Filename, FileSize, Modified, Accessed , Created ) ;
    values ;
    (tnId, oFile.Name, oFile.Size, ;
    oFile.DateCreated, oFile.DateLastModified, oFile.DateLastAccessed)
Endfor
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
Répondre
Fil
Voir

Click here to load this message in the networking platform