Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Retrieve information on all available drives

Total Hit ( 3134)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


You can retrieve information about all the available drives using calls to Windows API, if you like the hard way of doing things. A much simpler solution is offered by the Microsoft Scripting Runtime library, that exposes a Drive object that lets you get all those info by querying a property:

Click here to copy the following block
' NOTE: this code requires that you add a reference to the
'    Microsoft Scripting Runtime type library

Dim fso As New Scripting.FileSystemObject
Dim drv As Scripting.Drive
Dim info As String

For Each drv In fso.Drives
  ' display drive name and type
  info = "Drive " & drv.DriveLetter & vbCrLf
  info = info & " Type: "
  ' we must decode this value
  Select Case drv.DriveType
    Case Removable: info = info & "Removable" & vbCrLf
    Case Fixed: info = info & "Fixed" & vbCrLf
    Case CDRom: info = info & "CDRom" & vbCrLf
    Case Remote: info = info & "Remote" & vbCrLf
    Case RamDisk: info = info & "RamDisk" & vbCrLf
    Case Else: info = info & "Unknown" & vbCrLf
  End Select

  If Not drv.IsReady Then
    ' if the drive isn't ready we can't do much more
    info = info & " Not Ready" & vbCrLf
  Else
    ' retreive all additional info
    info = info & "  File System: " & drv.FileSystem & vbCrLf
    info = info & "  Label: " & drv.VolumeName & vbCrLf
    info = info & "  Serial number: " & drv.SerialNumber & vbCrLf
    info = info & "  Total space: " & drv.TotalSize & vbCrLf
    info = info & "  Free space: " & drv.FreeSpace & vbCrLf
  End If
  
  ' do something with the gathered info
  ' (display in a textbox in this case)
  Text1.Text = Text1.Text & info
Next


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.