You can use the Directory.GetFiles method
Also see Directory.GetFiles method (String, String, SearchOption)
You can specify a search option in this overload.
TopDirectoryOnly : includes only the current directory in the search.
AllDirectories . Includes the current directory and all subdirectories in the search operation. This option includes reprocessing points, such as installed drives and search symlinks.
// 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;
rahul Feb 11 2018-10-11T00 : 10-11
source share