How to check if folders have files?

daveofgv

Well-known member
Joined
Sep 17, 2008
Messages
218
Location
Dallas, TX
Programming Experience
1-3
Hello All -

Can anyone help guide me to find how I can search a directory (100 + folders) and see if each subfolder has files inside them?

Example:

root directory
- 123456789 (subfolder)
-------- image.tif
- 987654321 (subfolder)
-------- image.tif
- 897856543 (subfolder) ----- this folder will be logged (or moved) because it dosn't have any files in it

- 232132344 (subfolder)
-------- anotherimage.tif


Would anyone help let me know what I will need to do?

Thanks in advanced

daveofgv
 
This question has nothing to do with Windows Forms so I have moved it to a more appropriate forum.

The IO.Directory class has both GetDirectories and GetFiles methods. You can call GetDirectories for the root folder path to get an array containing all the subfolder paths. You can then loop through that and call GetFiles for each one to get an array of all the file paths. The Length of that array will tell you whether there are files in the folder or not.
 
Back
Top