Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ali Koumaiha
  Where is Ali Koumaiha?
 Farmington Hills
 Michigan - Lebanon
 Ali Koumaiha
 To: Cecil Champenois
  Where is Cecil Champenois?
 Little Elm
 Texas - United States
 Cecil Champenois
 Tags
Subject: RE: ADIR() Limitations
Thread ID: 416156 Message ID: 416168 # Views: 47 # Ratings: 2
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Monday, December 22, 2014 10:37:27 PM         
   


Cecil,
try this recursive function to get all the files in directory and in sub directory. you can tweak the line that does the ? to concole to store in your cursor.

It's small code and neat.


* your code here
CLEAR 
oDefault = SET('Default')
GetAllFiles('V:\Email_Attachments\KMart_Sears\2012\Att_Ex')
SET DEFAULT TO &oDefault 

FUNCTION GetAllFiles(cDirectory)
	*!*        EXTERNAL ARRAY aryAllFiles
	LOCAL ARRAY aryTemp(1,5)
	LOCAL nCount, nMax, nLen, cFile
	cDirectory = ADDBS(cDirectory)
	SET DEFAULT TO (cDirectory)
	=ADIR(aryTemp, "*.*","AHRSD",1)
	nMax = ALEN(aryTemp,1)
	FOR nCount = 1 TO nMax
		cFile = ALLTRIM(aryTemp(nCount,1))
		IF !(cFile == ".") AND !(cFile == "..")
			IF "D" $ aryTemp(nCount,5)
				GetAllFiles(ADDBS(cDirectory + cFile))
			ELSE
				lcFileName = aryTemp(nCount,1)
				lnFileSize = aryTemp(nCount,2)
				ldFileDate	= aryTemp(ncount,3)
				
				? cDirectory,lcFileName,lnFileSize, ldFileDate
			ENDIF
		ENDIF
	ENDFOR
ENDFUNC



ENTIRE THREAD

ADIR() Limitations Posted by Cecil Champenois @ 12/22/2014 7:36:30 PM
RE: ADIR() Limitations Posted by Tore Bleken @ 12/22/2014 7:45:21 PM
RE: ADIR() Limitations Posted by Cecil Champenois @ 12/22/2014 8:50:46 PM
RE: ADIR() Limitations Posted by Greg Green @ 12/22/2014 9:02:11 PM
RE: ADIR() Limitations Posted by Cecil Champenois @ 12/22/2014 9:56:15 PM
RE: ADIR() Limitations Posted by Ali Koumaiha @ 12/22/2014 10:37:27 PM