Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Something like 'Filer'
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00450922
Message ID:
00451695
Views:
37
Hi Michell,

This program can help you get started. Modify it for your needs.
********************************************************************************
*  Description.......: GetAllFiles1 - builds list of all files in directory tree
*                    : uses Adir recursive call
*  Calling Samples...:
*  Parameter List....: tcStartDir, tcFileExt
*  Created by........: David Frankenbach
*  Modified by.......: 
********************************************************************************
* ADIR() method of recursively building the file list - Dave Frankenbach
lparameters tcStartDir, tcFileExt
* tcStartDir - top directory to start from
* tcFileExt - only files with this extension would be added to the list,
*             leave blank for all file extensions

* Both parameters should be character type, check it first
**************************************************************************
if empty(tcStartDir) or vartype(tcStartDir)<>'C'
     tcStartDir='c:\' && Get list of files in the whole local drive
else
     tcStartDir=addbs(tcStartDir)
endif
if empty(tcFileExt) or vartype(tcFileExt)<>'C'
     tcFileExt='' 
endif

local ltStart
ltStart = datetime()
local lnTotNumberOfFiles

create cursor curFilesADIR (cFilename c(100), nSize n(10), dMod d, Flag L)
=RecurseFolder(tcStartDir, tcFileExt) && Call recursive procedure
lnTotNumberOfFiles=reccount(curFilesAdir)
? datetime() - ltStart, lnTotNumberOfFiles

index on upper(justfname(cFileName)) tag cFileName
browse nowait

function RecurseFolder
lparameters lcDir, lcFileExt
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
               if empty(lcFileExt) or justext(laFiles[i,1])==lcFileExt
                    llFlag=.f. 
                         insert into filesADIR ;
                         values( lcDir + laFiles[i,1], laFiles[i,2], laFiles[i,3],llFlag )
               endif
          endif
     endif
endfor
return
>I don't need to click or drag anything. I don't want a UI at all. All I want is a routine that I can feed a string to and have it return a list of files (in a cursor or array) that contain that string.
>
>I can't really assume ActiveDesktop. For now, it's for internal use, but we may sell the utility if it works out. I need to plan ahead.
>
>Looks like I'm just going to have to write it myself to get what I want. :)
>
>Thanks,
>
>Michelle
>
>>If the machine has the ActiveDesktop installed, you can use the Shell.Application object's FindFiles method. While it doesn't allow editing by double clicking the result, dragging a file into the Command window causes VFP to open it in the desired builder.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform