Add a flag and then look for it after the loop completes. It seems as though you are looping through the files instead of calling this recursively. I am guessing you have only one loop right now.
Before Loop iteration:
Dim FilesBeingAdded as Boolean = False
Dim numFiles2 as Integer = 0
Inside of iteration:
If item.InnerText.Contains(".") Then 'is a file
If FilesBeingAdded = False Then
FilesBeingAdded = true
End If
If Dir$(item.InnerText) <> vbNullString Then
mySize += FileLen(item.InnerText)
End If
zip.AddFile(item.InnerText, "")
numFiles2 +=1
Else 'is a directory
zip.AddDirectory(item.InnerText, GetLastDirName(item.InnerText & " "))
Dim dinfo As New DirectoryInfo(item.InnerText)
Dim sizeOfDir As Long = DirectorySize(dinfo, True)
Dim numFiles As Integer = CountFiles_FolderAndSubFolders(item.InnerText)
Console.WriteLine("...Added all " & numFiles & " files. Total directory size is {0:N2} MB", (CDbl(sizeOfDir)) / (1024 * 1024))
Console.WriteLine(vbCrLf)
End If
After Loop Iteration:
If FilesBeingAdded = True Then
mySize = BytesTO(mySize, convTo.MB)
Console.WriteLine("...Added all " & numFiles2 & " files. Total loose file collection size is " & Math.Round(mySize, 2) & " MB")
Console.WriteLine(vbCrLf)
mySize = 0
numFiles2 = 0
FilesBeingAdded = False
End If
So when it finishes the current iteration it will take the tally of files it added, along with the size and print it to the console. It then zeros the variables so that the next iteration of the inner loop has clean values. I am presuming you run this on more than one directory. By checking FilesBeingAdded
you can be sure to avoid situations where an ugly zero count output is shown if the directory contained no files.
This solution presumes a lot about how you enter this piece of code. If my presumptions were not correct, please modify the question to enable a better solution.