Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning folders total from a drive(s)
Message
 
To
11/10/2001 05:19:32
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00566830
Message ID:
00566899
Views:
18
Here is a program I have used to get a list of all files and directories on a drive.
* MakeTree.PRG
PARAMETERS RootPath	&& = "C:" or "D:"

#define cFileName   1
#define cFileSize   2
#define cFileDate   3
#define cFileTime   4
#define cFileAttrib 5

PRIVATE i, FileCnt, FileAry, TotSize, TotCnt

wait window nowait "Searching " + RootPath

TotCnt  = 0
TotSize = 0
IF NOT USED("TREE")
    USE Tree in 0 excl
    SET SAFETY OFF
    ZAP
    SET SAFETY ON
ENDIF
IF NOT USED("DIRTREE")
    USE DirTree in 0 excl
    SELECT DirTree
    SET SAFETY OFF
    ZAP
    SET SAFETY ON
ENDIF

FileCnt = ADIR(FileAry, RootPath + "\*.*", "DSH")

FOR i = 1 TO FileCnt
    IF AT("D", FileAry[i, cFileAttrib])  > 0
	IF FileAry[i, cFileName] # "."		&& skip "." and ".."
		= MakeTree(RootPath + "\" + FileAry[i, cFileName])
	ENDIF
    ELSE
	TotCnt  = TotCnt + 1
	TotSize = TotSize + FileAry[i, cFileSize]
	Period = RAT(".",FileAry[i, cFileName])
	IF Period > 0
		FileExt = SUBSTR(FileAry[i, cFileName], Period + 1, 3)
	ELSE
		FileExt = ""
	ENDIF
	INSERT INTO DirTree VALUES ;
		(RootPath, FileAry[i, cFileName], FileAry[i, cFileSize], ;
			   FileAry[i, cFileDate], FileAry[i, cFileTime], ;
			   FileAry[i, cFileAttrib], FileExt)
    ENDIF
ENDFOR

INSERT INTO Tree VALUES (RootPath, TotCnt, TotSize)

RETURN
Hope this helps.
Dennis Lindeman
Previous
Reply
Map
View

Click here to load this message in the networking platform