Zamaster wrote:How would I go about creating a program that searches every folder in a certain path and can then look at then files in that folder? Like a virus search program. So, itd look in a path ilke "C:" and look through all folders and look at the files in its current folder. Even better, let the user specify a path.
First of all, since this is a QB site, I assume the program you want to write will be in QB. If not, then forget the rest of this post.
You mention the word "folder", which is a Windows term. QB runs under DOS, and "folders" in DOS are called "directories". In DOS, both filenames and directories have the following format:
FFFFFFFF.EEE
where FFFFFFFF is a filename with a maximum of 8 characters, and EEE is a file-extension with a maximum of 3 characters.
Windows allows long filenames, where its filenames and folder names can exceed the DOS maximums.
So, if you are looking through a "folder" and encounter a filename or another folder, that exceeds the DOS maximum, the QB or DOS commands will cause an error. In Lurah's example, he has a file at C:\GAMES\TESTDRIVE.
This is fine for Windows, but TESTDRIVE has more than 8 characters and QB/DOS cannot handle it.
QB only has a few statements for handling directories, which includes CHDIR (Change default directory). However, I don't suggest you use this for your program.
What I suggest is using the DIR command to give you a list of all the filenames in the directory structure that you want to process. Your program should do a SHELL command specifying the required DIR redirecting the output to a work file.
Then read the workfile, get each filename, skip filenames that are not valid for DOS, and process each of the files according to your requirements.
Unfortunately, my Windows machine is down so I'm running on a Linux machine, and can't test the DIR command that you will need. Get on the MSDOS commandline and do:
DIR /?
and figure out how to get the list of all the directory+filenames that you need. Do some testing. This is the critical part of your solution. The DIR has to work. BTW, the DIR will also display all Windows' long file names.
Holler if you need any help.
*****