Click here to Skip to main content
15,900,511 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hello ALL,
I need a such function that take a folder path as input and gives the no of all files and folders including sub folders as output.Please help as soon as possible....
Posted
Comments
StianSandberg 24-Jul-12 8:19am    
You don't have to write "Please help as soon as possible".. There are a lot of people here helping as fast as they can..
shivammpi123 24-Jul-12 8:21am    
ok my dear.....
Dave Kreskowiak 24-Jul-12 19:58pm    
and don't call people you don't know "dear". That term is reserved for your wife or girlfriend.
Sandeep Mewara 24-Jul-12 8:24am    
What have you tried so far? Where are you stuck?
shivammpi123 24-Jul-12 8:30am    
I have tried following but it gives only the root folder filed details...not all sub directories info...
DirectoryInfo dir = new DirectoryInfo(@"C:\AddOn\");
Console.WriteLine(dir.GetFiles().Length.ToString());

1 solution

C#
var path = @"L:\";
int files = System.IO.Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Count();
int dirs = System.IO.Directory.GetDirectories(path, "*", SearchOption.AllDirectories).Count();
 
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