Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Directory and File List.
Message
From
04/04/2002 05:17:31
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00640628
Message ID:
00640758
Views:
28
This message has been marked as the solution to the initial question of the thread.
>Hi!
>
>How should I do to take a complete list of directory and files?
>Example:
>
>The user type: "C:\MY FILES"
>
>And I have to list all folders, all files - including system, read-only, hidden, etc. I have get the folder that don't have files too.
>
>TIA
? GetTree(Getdir(),'*.*',.T.)
GO top
brow

FUNCTION GetTree
LPARAMETERS tcStartDir,tcSkeleton,tlSubfolders
Create Cursor filelist ;
  (filepath c(50), filename c(20), ;
  filesize i, fattr c(8), createtime T, lastacc T, lastwrite T)
oFiler = Createobject('filer.fileutil')
With oFiler
  .SearchPath = tcStartDir
  .Subfolder = tlSubfolders
  .SortBy = 1
  .FileExpression = tcSkeleton
  .Find(0)
  For ix=1 To .Files.Count
    With .Files(ix)
      If !(Bittest(.Attr,4) And .Name = '.')
        Insert Into filelist ;
          (filepath, filename, filesize, fattr, createtime, lastacc, lastwrite)  ;
          values ;
          (.Path, .Name, .Size, Attr2Char(.Attr), ;
          Num2Time(.Datetime), Num2Time(.LastAccessTime), Num2Time(.LastWriteTime))
      Endif
    Endwith
  Endfor
  RETURN .Files.Count
Endwith

Function Num2Time
Lparameters tnFloat
Return Dtot({^1899/12/30}+Int(tnFloat))+86400*(tnFloat-Int(tnFloat))

Function Attr2Char
Lparameters tnAttr
*!*	#Define FILE_ATTRIBUTE_READONLY             0x00000001
*!*	#Define FILE_ATTRIBUTE_HIDDEN               0x00000002
*!*	#Define FILE_ATTRIBUTE_SYSTEM               0x00000004
*!*	#Define FILE_ATTRIBUTE_DIRECTORY            0x00000010
*!*	#Define FILE_ATTRIBUTE_ARCHIVE              0x00000020
*!*	#Define FILE_ATTRIBUTE_ENCRYPTED            0x00000040
*!*	#Define FILE_ATTRIBUTE_NORMAL               0x00000080
Return ;
  IIF(Bittest(tnAttr,0),'RO','RW')+;
  IIF(Bittest(tnAttr,1),'H','_')+;
  IIF(Bittest(tnAttr,2),'S','_')+;
  IIF(Bittest(tnAttr,4),'D','_')+;
  IIF(Bittest(tnAttr,5),'A','_')+;
  IIF(Bittest(tnAttr,6),'E','_')+;
  IIF(Bittest(tnAttr,7),'N','_')
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform