You are here:

Visual Basic/filesearch from folders

Advertisement


Question
sampleFile
sampleFile  
Dear Sir,
I have a Main Folder and that has so many sub folders in it.
Any sub folder from a Main folder has several MS-word documents saved with EmployeeeName and Sno as File name.
Eg:Hameed-100.doc, Hameed-102.doc

I want to get path of given document name by providing Employee name from a TextBoxe.
Please see the attached sample image for better understanding.
thanks you so much sir.

Answer
Dear Hameed,

To get a list of the files in a directory, check this link:

http://www.developerfusion.com/code/3681/list-files-in-a-directory/

To get a list of the files in all subfolders check those links:

http://stackoverflow.com/questions/21595143/get-all-the-folders-and-sub-folders-

http://stackoverflow.com/questions/9427495/fast-file-listing-incl-sub-folders

Using code from above links, get list of all files. Modify list to save path with each file name (use 2-dimentional array or add column to a listbox).

Next step go through the list, using any loop: say, for... next loop, find the file and get corresponding path

If the file found, get the path, and get out of the loop.


Sincerely,

Vitaly

Visual Basic

All Answers


Answers by Expert:


Ask Experts

Volunteer


VITALY

Expertise

Area of expertise is Visual Basic .NET (VS 2008 and Framework 3.5) design and development for Windows applications. You can ask me any Visual Basic questions and some questions about .NET Framework. You can also ask me how to use Component One controls in Visual Basic. Do not ask me questions about Web design and development in Visual Basic.

Experience

I'm working as VB programmer from 1997, so I have a lot of experience with Visual Basic .NET as well as Visual Basic 6. Area of expertise is Visual Basic .NET (VS 2008 and Framework 3.5) design and development for Windows applications; Component One controls for Visual Basic; User controls; Moving VB6 applications to .NET.

Education/Credentials
B.S. in Computer Science

©2016 About.com. All rights reserved.