?
Solved

How to get  the free space  of a hard drive

Posted on 2005-04-21
7
Medium Priority
?
199 Views
Last Modified: 2013-12-26
How to get  the free space  of network PC's hard drive (i have three PC in network i want to get free space of other two PC,s through VB6)
0
Comment
Question by:ADhiman
  • 4
  • 2
7 Comments
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 13833145
0
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 13833176
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ADhiman
ID: 13840416
i have PC Based upon IP address
is there any solution Like(i will put IP address of that PC and  drive name it will show free space)
0
 
LVL 10

Expert Comment

by:edwardiii
ID: 13852160
Hi, ADhiman.

This solution may help you.  I slightly modified the code found at (http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20064358.html?query=drive+free+space&topics=93):

Private Sub CommandButton1_Click()
On Error GoTo Errorhandler

    Dim fso As New Scripting.FileSystemObject, dr As Scripting.Drive
    For Each dr In fso.Drives
        MsgBox "Drive letter:           " & dr.DriveLetter & vbNewLine & "Drive Total Size:     " & Format(dr.TotalSize, "#0,000") _
        & " Bytes" & " / " & Format(dr.TotalSize / 1000000000, "#0.00") & " GB" & vbNewLine & "Drive free space     " & Format(dr.FreeSpace, "#0,000") & " Bytes" _
        & " / " & Format(dr.FreeSpace / 1000000, "#0.00") & " MB"
    Next
    Exit Sub
   
Errorhandler:
    MsgBox "Drive letter: " & dr.DriveLetter & "--not ready."
    Resume Next

End Sub

0
 
LVL 10

Accepted Solution

by:
edwardiii earned 1500 total points
ID: 13855288
To build on the above, since it will acquire all mapped drives, you can populate a Combobox with all mapped/local drives you've got access to, then select one to get that
drive's info:

In your form's General Declarations:

     Public fso As New Scripting.FileSystemObject
     Public dr As Scripting.Drive


In your form's load event:

     ComboBox1.Text = "Select a drive"
     For Each dr In fso.Drives
            ComboBox1.AddItem dr.DriveLetter
     Next

In your Combo box's Change event:

    On Error GoTo Errorhandler

    Set dr = fso.GetDrive(ComboBox1.Text)
    MsgBox "Drive Total Size:     " & Format(dr.TotalSize, "#0,000") _
    & " Bytes" & " / " & Format(dr.TotalSize / 1000000000, "#0.00") & " GB" & vbNewLine & "Drive free space     " & Format(dr.FreeSpace, "#0,000") & " Bytes" _
    & " / " & Format(dr.FreeSpace / 1000000, "#0.00") & " MB"

    Exit Sub
Errorhandler:
   
    If ComboBox1.Text <> "Select a drive" Then
        MsgBox "Drive letter: " & ComboBox1.Text & "--not ready."
    End If
    Resume Next
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question