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

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2007
Posts: 26
Reputation: BalagurunathanS is an unknown quantity at this point 
Solved Threads: 0
BalagurunathanS's Avatar
BalagurunathanS BalagurunathanS is offline Offline
Light Poster

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

 
0
  #1
Sep 19th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

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

 
0
  #2
Sep 19th, 2007
Try this:
  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.
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 9
Reputation: scottb2 is an unknown quantity at this point 
Solved Threads: 0
scottb2's Avatar
scottb2 scottb2 is offline Offline
Newbie Poster

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

 
0
  #3
Sep 24th, 2007
This is slightly modified from the VB 2005 .NET help files. lstInfo is a listbox in my test application.
  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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC