Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Recursive function for directory read
Message
De
03/05/2001 03:07:49
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00502783
Message ID:
00502881
Vues:
21
>Has anyone written or know where to find a function to capture folder and file details? I don't think there's a need to reinvent the wheel...
>
>Thanks!!!

Gil,
You might also try :
Gettree('c:\')
Function gettree
Lparameters tcDirectory
Start = seconds()
oFS = CREATEOBJECT('Scripting.FileSystemObject')
oFolder = oFS.GetFolder(tcDirectory)
Dimension aFolders[1,1]
aFolders[1]=tcDirectory
tcDirectory = iif(oFolder.IsRootFolder(), substr(tcDirectory,1,len(tcDirectory)-1), tcDirectory)
=_SubFolders(oFolder, tcDirectory, tcDirectory)
Asort(aFolders)
? seconds()-start
Create cursor crsFolders (Folder m)
Append from array aFolders
Go top
Browse

Function _SubFolders
Lparameters toFolder, tcPath, tcStartPath
Local loSubFolders
tcPath = tcStartPath
For each oSubFolder in toFolder.Subfolders
  If oSubFolder.Name # "System Volume Information"
    Dimension aFolders[alen(aFolders,1)+1,1]
    aFolders[alen(aFolders,1),1] = tcPath+"\"+oSubFolder.name
    =_SubFolders(oSubFolder, tcPath, tcPath+"\"+ oSubFolder.name)
  Endif
Endfor
oFS also has many other capabilities like :
oFolder = oFS.Getfolder('c:\Some folder')
for each oFile in oFolder.Files
  with oFile
  ? .Name, ;
    .DateCreated, ;
    .DateLastAccessed, ;
    .DateLastModified, ;
    .Size, .Type, ;
    .ShortName, .ShortPath 
  .Attributes = bitor(.Attributes,0x01) && Set read only
  endwith
endfor
oFS.CopyFolder(SourceDir, TargetDir)
Unlike ADIR() it can access to any folders.
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