: : : :
: : : : i am trying to build a program that scans all the harddisk for a file using Microsoft Visual Basic 6,i am using the dirlistbox control to find the directories,but the problem is that the dirlistbox control do not show the hidden folders,even if i choose to show the hidden files and folders from the tools menu,please if you can help me to find a way to let the dirlist control shows the hidden directories,
: : : : or if there is another way to find in all the directories including the hidden directories.
: : : :
: : : : Best Regards
: : : :
: : :
: : : Use the Dir function. With the first call supply the information through the arguments. Then, to find the rest, use Dir without arguments. You'll need to set up a loop of some sort (or maybe create a function that continues to call itself)
: : :
: : : Greets...
: : : Richard
: : I wouldn't.
: : A recursive function calling Dir() with parameters would reset the dir call; so once the function returns, the parent function's Dir() would b screwed up.
: : Besides, I find it's easier to use the FileSystemObject for these task.
: I refuse to use the filesystem object, especially if it is not for home usage. But even if it is, I wouldn't. I am sure there is a way of either using loops or recursive function calls to find all the files you need.
Of course there's one: first use Dir() and set parameters for it; then copy all the directories/files in two arrays, then iterate over each one again, consuming heaps of memory and CPU time in the process, and, once recursion gets deep enough, you also have good chances of the stack blowing out due to the larger memory footprint; moreover, I find that pretty annoying and error-prone.
While I know the limits of the FileSystemObject, I still prefer:
Function RecurseIterateFolder(ThisFolder as Folder)
Dim SubFolderObj as Folder
Dim FileObj as File
for each FileObj in ThisFolder.Files
'do what you need
for each SubFolderObj in ThisFolder.Subfolders
'perhaps skipping "." and "..", I can't remember
(note that I wrote those two lines right here and now, without trying them, so they might contain some silly errors and whatnot)
I just can't find any good reason to complicate things so mercilessly on oneself as to write things another way.
Compare this piece of code and others' in this thread, and tell me which one is easier and takes less time to code and debug.
But then, it's a matter of tastes.