944,083 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 6373
  • VB.NET RSS
Sep 19th, 2007
0

Need code to get free space and used space in hard drive ..

Expand Post »
Hi Friends..

I need to get the free space and used space in hard drive ..Can anyone provide me with the code..I need the code in VB.net..I need to see the space available in each drive individually..
Someone help in this regard as early as possible..

Regards,
Balagurunathan
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
BalagurunathanS is offline Offline
26 posts
since Apr 2007
Sep 19th, 2007
0

Re: Need code to get free space and used space in hard drive ..

Try this:
VB.NET Syntax (Toggle Plain Text)
  1. Dim dvr As New DriveInfo("c:")
  2. Label1.Text = CStr(dvr.TotalFreeSpace / 1000000) & " MB"
  3. Label2.Text = CStr(dvr.TotalSize / 1000000) & " MB"
  4. Label3.Text = CStr(Val(Label2.Text) - Val(Label1.Text)) & " MB"
Last edited by waynespangler; Sep 19th, 2007 at 11:09 am.
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Sep 24th, 2007
0

Re: Need code to get free space and used space in hard drive ..

This is slightly modified from the VB 2005 .NET help files. lstInfo is a listbox in my test application.
VB.NET Syntax (Toggle Plain Text)
  1. Dim alldrives() As DriveInfo = DriveInfo.GetDrives()
  2. Dim d As DriveInfo
  3.  
  4. For Each d In alldrives
  5. lstInfo.Items.Add(String.Format( _
  6. "Drive {0}", d.Name))
  7. lstInfo.Items.Add(String.Format( _
  8. " File type: {0}", d.DriveType))
  9.  
  10. If d.IsReady = True Then
  11. lstInfo.Items.Add(String.Format( _
  12. " Volume label: {0}", d.VolumeLabel))
  13. lstInfo.Items.Add(String.Format( _
  14. " File system: {0}", d.DriveFormat))
  15. lstInfo.Items.Add(String.Format( _
  16. " Available space to current user:{0, 12:N0} Mbytes", _
  17. d.AvailableFreeSpace >> 20))
  18.  
  19. lstInfo.Items.Add(String.Format( _
  20. " Total available space: {0, 12:N0} Mbytes", _
  21. d.TotalFreeSpace >> 20))
  22.  
  23. lstInfo.Items.Add(String.Format( _
  24. " Total size of drive: {0, 12:N0} Mbytes ", _
  25. d.TotalSize >> 20))
  26. End If
  27. Next
Reputation Points: 10
Solved Threads: 0
Newbie Poster
scottb2 is offline Offline
12 posts
since Sep 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: help in save/load database
Next Thread in VB.NET Forum Timeline: .NET General Newbie Qs





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC