ltStart = datetime() CREATE CURSOR iterADIR (cFileName C(254), nSize N(10), dMod D, cTime C(8), ATTRIB C(8)) INSERT INTO iterADIR VALUES ('c:\',0,{},'','D') GO TOP LOCAL aFiles[1,5], nFiles, cBasePath, iRecNo, nCtr * We will use a cursor to serve as a dynamically sized list DO WHILE ! EOF() * extract the path prefix in case we need it IF 'D' $ iterADIR.ATTRIB && this is a directory DIMENSION aFiles[1,5] ?? '.' cBasePath = ADDBS(ALLTRIM(iterADIR.cFileName)) aFiles = NULL nFiles = ADIR(aFiles, cBasePath + '*.*','SHD') * We may move the record pointer, so save its position iRecNo = RECNO() FOR nCtr = 1 TO nFiles * The IF statment below strips periods from the filename * If the filename is only made of '.', we will asume it's either * the relative folder entry '.' or the parent folder '..' IF LEN(ALLTRIM(CHRTRAN(aFiles[nCtr,1],'.',''))) > 0 * It's a legal file - add it to the tail of the list INSERT INTO iterADIR VALUES ( cBasePath + aFiles[nCtr,1], ; aFiles[nCtr,2], ; aFiles[nCtr,3], ; aFiles[nCtr,4], ; aFiles[nCtr,5] ) ENDIF ENDFOR GOTO iRecNo ENDIF SKIP ENDDO ? datetime() - ltStart>Thanks
* 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 > >