-
VB.net get free space
How do you get vb.net to read the figure that is displayed when you right click on a drive and do properties, under free space?
We can get free space of a drive, but its slighly different to the figure displayed there. Was wondering if there is some code to just read the figure from there.
-
Can you tell us the two amounts?
is one dividing by 1000 for bits and the other by 1024 for bits? it can change the size dramatically on large drives.
Give more details and we will see :)
-
wellll. this is weird!!!
i have just been building an application for work that does this...
you will need to add:
Imports System.IO
then this is how iv done mine..
Code:
Dim alldrives() As DriveInfo = DriveInfo.GetDrives
'setting up the main function for getting drive infomation
Dim a_total = Format(alldrives(10).TotalSize / 1024 / 1024 / 1024, "#0.0")
Dim a_freespace = Format(alldrives(10).TotalFreeSpace / 1024 / 1024 / 1024, "#0.0")
Label6.Text = a_total & " GB" 'total HDD Size
Label5.Text = a_freespace & " GB" 'Free space
'A nice progress bar!
ProgressBar1.Maximum = a_total
ProgressBar1.Minimum = 0
ProgressBar1.Value = a_freespace
the progress bar is set up how i like it, but you might want it diffrent.. let me explain..
lets use an example HDD size of 100GB and 80GB free
if you have
ProgressBar1.Value
set as:
ProgressBar1.Value = a_freespace
It will fill the progress bar 80%
but. if you have:
ProgressBar1.Value = a_total - a_freespace
it will fill the progress bar with used amount. so will only fill it 20%
OOOO! i forgot! you change what drive you are getting the infomation from with:
from:
alldrives(NUMBER HERE)
it takes a bit of playing about. but i found out, if you step through it. (and then over it, so its loaded the infomation into that VAR) then you can hover over the where alldrive() is defined and it will give you a list of drives and there ID number..
any more problems. give me a shout.. but thats what i use. and it works niceely :D