Find all files named test.txt in the folder

Question posted in Computer Software on 06 2010
Rate question difficulty level 0 Votes
You have an object named FolderObject that get the path of a specific folder and the name of the folder.

FolderObject has 2 functions :
1.find all sub folders
2.find all files (in the folder)

The question is :
write a function that get the folder name (for example c:\mydocuments) and a file name (for example test.txt) .
the function needs to return all the instances of the file in the folder , sub folders etc ...
 
 
8 Answers
 
You need to build a recursive function.
Since you need to search for all the files in the folders .
you don't know how many sub folders you will have.
I wrote my answerd in pseudo-code

1. func gerRecursiveFiles(string path,string file name)
2. find all the files in the folder = FolderObject .findAllFiles(filename)
3. comapre and look for the file name
4. if FolderObject .findAllFiles(filename).count =0 then return
5. look for all the folders :
for( int i=0; i{
gerRecursiveFiles(FolderObject.findAllFolders()[i], fileName)
}



06/02/2010
 
 
If time is money you've made me a waletiher woman.

01/11/2012
 
 

01/12/2012
 
 
 
 
 
 
 
 
 
 
 
 
Add an answer*
 
Your name
Email
 

add a question

arrow_blue


Now hiring!
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------
---------------------------