I have a logic problem, just need more brains working on this.
For Each JobNode In JobNodes
Dim Source = JobNode.SelectNodes("Source")
For Each item As System.Xml.XmlNode In Source
Dim infoReader As System.IO.FileInfo
''''Discerns whether a file or directory
If item.InnerText.Contains(".") Then 'is a file
If Dir$(item.InnerText) <> vbNullString Then
mySize += FileLen(item.InnerText)
End If
zip.AddFile(item.InnerText, "")
Dim numFiles2 = filenames.Count
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)
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
Next
This is part of a backup program I made. This is the part that determines if the object to be added to the zip is a file (first part of the IF statement) or a directory (ELSE part of the IF statement).
My problem is, I am trying to add this code:
Dim numFiles2 = filenames.Count
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)
Just after the zip.AddFile(item.innertext,"")
part. I want to add this so that I can get a console print out of the information.
The problem is, if I just put it directly after the zip.addfile()
, it outputs the code directly above each time. I only want it to print out that part (directly above) once it has finished adding all of the loose files (or files added using zip.AddFile()
)
EDIT: adding the for loops at the top for more clarification