1 Replies - 164 Views - Last Post: 29 December 2019 - 06:19 PM Rate Topic: -----

#1 Nicomendox   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 05-March 16

How can I Get Sum Total Size of Directories Which Listed in ListBox?

Posted 29 December 2019 - 04:19 PM

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


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


What I am doing Wrong ?

Is This A Good Question/Topic? 0
  • +

Replies To: How can I Get Sum Total Size of Directories Which Listed in ListBox?

#2 Nicomendox   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 05-March 16

Re: How can I Get Sum Total Size of Directories Which Listed in ListBox?

Posted 29 December 2019 - 06:19 PM

I didn't do anything but it's already working...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1