Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to work with files in system/hidden folders
Message
De
08/01/2000 18:49:59
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00314887
Message ID:
00315018
Vues:
60
>Ed,
>
>Thanks for posting the WSH version. My tests conclude it is 8 to 9 times slower than the equivalent ADIR() based code. Here's the full disk traverse ADIR version:
>

No question; it's lots slower, thanks in part to having to make a ton of calls through a COM interface! The file names that caused problems were variant LFNs; LFNs with multiple '.'s in the name, possibly in sequence, was at least one place ADIR fouled up. I'm sure that I could improve the performance significantly by building a script component that returned a Scripting.Dictionary collection or ADO recordset if it were a major issue.

The availability of some of the native Scripting.FileSystemObject still might make it attractive; for example, it'd be trivial to return the short path (the 8.3 compliant full path rather than the LFN, since it's just a different property of the File object (the ShortPath property). And you can set/get file attributes, get all three of the date stamps if your file system supports it. It's also nice having distinct collections of files and folders, and the wealth of file, folder and drive manipulation methods built into the component.

I'm really looking forward to other new system components that are just around the bend- ADSI is neat, and WMI looks to be even better!

I hope you don't mind, but I've tried to standardize the behaviors of both of our routines so that others can get a direct comparison of how we implemented them. That should make it easy for people to compare apples to apples. I've made minor changes to yours, and did a few things to better optimize mine, like adding some WITH..ENDWITH statements to minimize the object reference overhead. Feel free to make improvements. FWIW, I ran this on an NT box (NT Enterprise Server, 256MB, 11,509 files) and the ADIR() method was 3-16 times faster, but it missed two files - C:\TEMP\...txt and C:\TEMP\.again. It had no problems with names that didn't start with a '.'

The ADIR() ran faster after each subsequent pass; FSO improved slightly after the first pass, but took about the same time on subsequent passes.
* ADIR() method of recursively building the file list - Dave Frankenbach
ltStart = datetime()

create cursor filesADIR ( cFilename c(80), nSize n(10), dMod d )

RecurseFolder( "c:\" )
? datetime() - ltStart

index on nSize tag nSize

browse nowait

function RecurseFolder( lcDir )
local i,n, laFiles[1]

?? "."
n = adir( laFiles, lcDir + "*.*", "shd" )

for i = 1 to n
   if ( left( laFiles[i,1], 1 ) != '.' )
      if ( "D" $ laFiles[i,5] )
         RecurseFolder( lcDir + laFiles[i,1] + "\" )
      else
        insert into filesADIR ;
               values( lcDir + laFiles[i,1], laFiles[i,2], laFiles[i,3] )
      endif
   endif
endfor
return

* Scripting.FileSystemObject example of recursive file list build - Ed Rauh
ltStartFSO = datetime()

create cursor filesFSO ( cFilename c(80), nSize n(10), dMod d )
oFSO = CreateObject('Scripting.FileSystemObject')

RecurseFolderFSO(oFSO.GetFolder('c:\'))
? datetime() - ltStartFSO

INDEX ON nSize TAG nSize
BROWSE

FUNCTION RecurseFolderFSO
LPARAMETER toFolderObject
?? "."
WITH toFolderObject
   FOR EACH oFile IN .Files
      WITH oFile
         INSERT INTO filesFSO ;
             VALUES (.Path, .Size, .DateLastModified )
      ENDWITH
   ENDFOR
   FOR EACH oSubFolder in .SubFolders
      RecurseFolderFSO(oSubFolder)
   ENDFOR
ENDWITH
toFolderObject = NULL
RETURN
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform