Andrew

Andrew

  • NA
  • 1
  • 0

Progress bars for drive size

Sep 5 2009 10:04 AM
I'm trying to make progressbars to display space used on the drives on the computer on the fly. My code is: [code] Private Sub DriveBox_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DriveBox.VisibleChanged Dim allDrives() As DriveInfo = DriveInfo.GetDrives() Dim d As DriveInfo Dim AvSpace As Integer Dim ToAvSpace As Integer Dim TotSpace As Integer Static num As Integer Dim NewProgressBar(num) As Control num += 1 For Each d In allDrives If d.IsReady = True Then If d.DriveType.ToString = "Fixed" Then lstdrives.Items.Add(d.Name) lstdrives.Items.Add(d.VolumeLabel) AvSpace = lstdrives.Items.Add(" Available space to current user: " & d.AvailableFreeSpace.ToString / 1024 / 1024 & " " & " MB") ToAvSpace = lstdrives.Items.Add(" Total available space: " & d.TotalFreeSpace.ToString / 1024 / 1024 & " " & " MB") TotSpace = lstdrives.Items.Add(" Total size of drive: " & d.TotalSize.ToString / 1024 / 1024 & " " & "MB") ReDim NewProgressBar(num) NewProgressBar(num - 1) = New ProgressBar() With NewProgressBar(num - 1) .Name = "Bar" & num .Location = New System.Drawing.Point(10, num * (.Height + 10)) End With Me.Controls.AddRange(New System.Windows.Forms.Control() {NewProgressBar(num - 1)}) Me.ProgressBar4.Value = (TotSpace - ToAvSpace) / 100 End If End If Next End Sub [/code]