Hi everyone.
I try to get size of directories (with all subdirectories) which I added into the Listbox by FolderBrowser
If I select one Folder
C:\Users\Yaman\Desktop\Folder1
I can get the size it but when I select 2 or more Folders into listbox
C:\Users\Yaman\Desktop\Folder1
C:\Users\Yaman\Desktop\Folder2
C:\Users\Yaman\Desktop\Folder3
programe gives me only last added Folder3 size
What I am doing Wrong ?Code:Private Sub getSizeBtn_Click(sender As Object, e As EventArgs) Handles getSizeBtn.Click Dim sayi Dim bicim3 Dim lngDirectorySize2 As Long For i As Integer = 0 To ListBox1.Items.Count - 1 If IO.Directory.Exists(Me.ListBox1.Items.Item(i).ToString) Then lngDirectorySize2 = lngDirectorySize2 + (From strFile In My.Computer.FileSystem.GetFiles(Me.ListBox1.Items.Item(i).ToString, FileIO.SearchOption.SearchAllSubDirectories) Select New System.IO.FileInfo(strFile).Length).Sum() End If Next i MsgBox(lngDirectorySize2) sayi = (CDec(Fix((lngDirectorySize2 / 1 / 1) * 100) / 100)) bicim3 = Format(sayi, "#,#.##") MsgBox(bicim3) End Sub




Reply With Quote
