On 25-Jan-2005 S�ren Breddam wrote:
> Does anybody know how to search for files in a directory and all
> subdirectories with Mapbasic?
> I want to do some batch processing on all my tab-files, but I'm stuck. I
> can currently only search in one directory with FindFirstFile and
> FindNextFile...
As you read file names FindNextFile after the first call to
FindFirstFile, keep track of the file type. If it's a directory, then add
it to the path you used for FindfirstFile, and call FindFirstFile with
that and search the new directory.
The best way to thoroughly search directories and subdirectories is to do
it recursively. Here's a psuedo-code example that recursively searches the
entire C: drive, printing the name of each Tab file found:
set variable path to "C:\"
call PrintTab() with path
sub PrintTab (byval sPath as string)
call FindFirstFile
do
if the file is a directory and not ".\" or "..\" then
call PrintTab with path + file + "\"
else if it is a tab file
print the file name
end if
get next file with FindNextFile
while next file was found
end sub
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 14990