Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make a program where a user input starting path, then search all hrd drive and directories under the path provided by the user.
How to achieve this ?
do i have to use recursion? please help me
Posted
Comments
ZurdoDev 8-Feb-12 16:35pm    
There are built-in classes under System such as File and Folder to allow you to do this. You should get started in it and then ask specific questions because this is way too vague.

What you want to use is the DirectoryInfo object and the GetFiles method.

C#
string userInputPath = string.Empty;
string fileType = string.Empty;

//Set parameters to what you need

System.IO.DirectoryInfo dInfo = new System.IO.DirectoryInfo(userInputPath);
var files = dInfo.GetFiles(fileType, System.IO.SearchOption.AllDirectories);


Here is the reference on MSDN[^]. It is pretty straight forward.
 
Share this answer
 
v2
You can use
C#
DirectoryInfo[] GetDirectories(
    string searchPattern,
    SearchOption searchOption
)


read this[^] and this[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900