How do I get number of Files from a folder using ASP.NET with C#?
You can use the Directory.GetFiles method
Also see Directory.GetFiles Method (String, String, SearchOption)
You can specify the search option in this overload.
TopDirectoryOnly: Includes only the current directory in a search.
AllDirectories: Includes the current directory and all the subdirectories in a search operation. This option includes reparse points like mounted drives and symbolic links in the search.
// searches the current directory and sub directory int fCount = Directory.GetFiles(path, "*", SearchOption.AllDirectories).Length; // searches the current directory int fCount = Directory.GetFiles(path, "*", SearchOption.TopDirectoryOnly).Length;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With