Quote Originally Posted by passel View Post
Code:
ListBox1.Items.AddRange(IO.Directory.GetDirectories("Z:\Documents"))
He did have multiple directories in the list.
The above line adds all the directories that are in Z:\Documents to the Listbox (note "AddRange" and "GetDirectories". GetDirectories returns an array of directory paths and AddRange adds all the elements of the array to the list.

The code then gets the size of each of the directories (and the subdirectories below those directories) and gives the sum.

That is what you said you wanted.

A test more similar to your posts.
Code:
 Public Class Form1

  Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    ListBox1.Items.Add("C:\users\passel\Desktop\Tools")  '7.5 MB
    ListBox1.Items.Add("C:\users\passel\Desktop\DeskTop Collection 2")  '691 MB
    ListBox1.Items.Add("C:\users\passel\Desktop\DeskTopCollection")  ' 121 MB

    Dim dirSize As Long = ListBox1.Items.Cast(Of String).Sum(Function(s) (From strFile In My.Computer.FileSystem.GetFiles(s, FileIO.SearchOption.SearchAllSubDirectories) Select New IO.FileInfo(strFile).Length).Sum())
    MsgBox((dirSize / 1024) / 1024) 'MB
  End Sub
End Class
The message box shows the total 820.675497..... so matches the expected size of the three directories sizes (as noted in the comments).

I just removed one of the "/ 1024" so it is in MB rather than GB.

You said it is working, so I assume it is good for you. I guess you just assumed he was adding only one directory to the Listbox, rather than all the directories from the Z:\Documents folder.

Yes. its working. thanks a lot.