计算图像驱动器中的文件/文件夹/子文件夹

时间:2016-03-21 14:26:02

标签: .net file-io count

计算图像驱动器中的文件/文件夹/子文件夹有时会显示不准确的计数,无论是使用Windows资源管理器还是使用visual studio.net进行计数......

Public Sub procGetTotalCountFiles(ByVal DirPath As String, Optional IncludeSubFolders As Boolean = True)
        Dim objFileInfo As ZlpFileInfo
        Dim objDir As ZlpDirectoryInfo = New ZlpDirectoryInfo((DirPath))
        Dim objSubFolder As ZlpDirectoryInfo
        Dim strSourceFullName As String : Dim strSource As String : Dim strFolder As String

        Try
            For Each objFileInfo In objDir.GetFiles()
                intCountAllFiles = intCountAllFiles + 1               
                dblFolderWeight += objFileInfo.Length               
            Next
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

        For Each objSubFolder In objDir.GetDirectories()
        uintCountFolders = uintCountFolders + 1
        Call procGetTotalCountFiles(strSourceFullName)
        Next
        objFileInfo = Nothing : objDir = Nothing : objSubFolder = Nothing
end sub

0 个答案:

没有答案