Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 27th, 2005, 11:13 AM   #1
fox123
Newbie
 
Join Date: Mar 2005
Posts: 25
Rep Power: 0 fox123 is on a distinguished road
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
fox123 is offline   Reply With Quote
Old Aug 27th, 2005, 11:16 AM   #2
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
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 .
Polyphemus_ is offline   Reply With Quote
Old Aug 27th, 2005, 11:33 AM   #3
fox123
Newbie
 
Join Date: Mar 2005
Posts: 25
Rep Power: 0 fox123 is on a distinguished road
how would i go about this? because i am quite new to vb
thanks
fox123 is offline   Reply With Quote
Old Aug 27th, 2005, 12:34 PM   #4
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
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
Polyphemus_ is offline   Reply With Quote
Old Aug 28th, 2005, 8:22 AM   #5
fox123
Newbie
 
Join Date: Mar 2005
Posts: 25
Rep Power: 0 fox123 is on a distinguished road
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
fox123 is offline   Reply With Quote
Old Sep 7th, 2005, 2:38 PM   #6
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
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 Routine

Calling ListDirectory would then list all files in a particular directory, including subdirectories.

Simple!
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:16 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC