sanjshah12
asked on
Get number of Files in Directory and Sub Directories
Hi,
I am using the code below to obtain the number of files in a directory but would like to also check the number of files that might be present in any sub directories of the main folder, I need this to be efficient as I am checking several 50+ directories so have used GetFiles as some posts on stackoverflow say this is the most efficient method.
Any help is appreciated.
I am using the code below to obtain the number of files in a directory but would like to also check the number of files that might be present in any sub directories of the main folder, I need this to be efficient as I am checking several 50+ directories so have used GetFiles as some posts on stackoverflow say this is the most efficient method.
Dim FullPath As String = (Server.MapPath("~\Docs\" & strDirectoryPath))
If Directory.Exists(FullPath) Then
Dim s() As String = Directory.GetFiles(FullPath)
If s.Length = 0 Then
Return "Empty"
Else
Return String.Format("{0} files/s", s.Length)
End If
Else
Return "Empty" 'Directory Does Not Exist
End If
Any help is appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER