|
-
Jul 22nd, 2005, 03:49 AM
#1
Thread Starter
Junior Member
Getting c drive free space info?
HI guys..i'm having a problem...how do you get drive space info for c drive only?...the ones i found in the forums lists down all the drives..what i want to do is to display out the available disk space left on drive c on a message box or label..anyone knows how?
-
Jul 22nd, 2005, 04:25 AM
#2
Re: Getting c drive free space info?
You need a reference to the Microsoft Scripting Runtime library. Select the Project menu's Add Reference command and click on the COM tab. Select the Microsoft Scripting Runtime entry and click OK.
'assuming you have a textbox to input a drive and a button to get it's information
Put this at the top of your class
Imports Scripting
for example if you want to get the free space of your c drive type in the textbox C:/ then press a button ok
Code:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
getinfodrive(TextBox1.Text)
End Sub
Sub getinfodrive(ByVal s As String)
Dim drive As String
Dim fso As New FileSystemObject()
For Each drive In Directory.GetLogicalDrives
If drive = s Then
Dim d As Drive = fso.GetDrive(drive)
MessageBox.Show(d.FreeSpace.ToString)
MessageBox.Show(d.TotalSize.ToString)
End If
Next
End Sub
-
Jul 22nd, 2005, 04:49 AM
#3
Thread Starter
Junior Member
Re: Getting c drive free space info?
The size is shown in bytes?..is there a way to convert it to kb?
-
Jul 22nd, 2005, 05:10 AM
#4
Member
Re: Getting c drive free space info?
1 kb is 1024 bytes. So it should be quite easy to calculate.
"Testing? What's that? If it compiles, it is good, if it boots up, it is perfect."
-Linus Torvalds
-
Jul 22nd, 2005, 06:21 AM
#5
Thread Starter
Junior Member
Re: Getting c drive free space info?
oh okay..thanks a lot..that solved it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|