![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2005
Posts: 25
Rep Power: 0
![]() |
Searching SubFolders
Hi,
I am writing a program to determine if a file exists. I can get the program to search a specified folder but i also need the program to search sub folders in the main folder sepecified. Is there any simple way of doing this? Thanks for your time |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
well, if you want to search through the folders.. just create a function which calls himself when a new dir is found, and stop all the functions when the file is in the directory
. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Mar 2005
Posts: 25
Rep Power: 0
![]() |
how would i go about this? because i am quite new to vb
thanks |
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Something like this:
public function CheckDir(the filename, the current directory)
loop through the directory content
if there is another directory found
CheckDir filename, the directory to search for now
else if a file has been found and it is called filename
CheckDir = the current directory
end if
end loop
end function |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Mar 2005
Posts: 25
Rep Power: 0
![]() |
Thanks but i am still confused. The main folder contains hundereds of different sub folders that need to be searched they are in no sequence aswell. I am quite a newbie
please help thanks |
|
|
|
|
|
#6 |
|
Expert Programmer
|
The dir function will always return items in alphabetical order.
The second parameter dictates which type(s) of objects are enumerated (files/folders/drives or objects with certain attributes). So your method might be Routine ListDirectory(Path)
List each directory and Call ListDirectory(directory's path)
List each file and add its path to list of items
End RoutineCalling ListDirectory would then list all files in a particular directory, including subdirectories. Simple! ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|