[VB.NET] Get Drive Information

CodeBreaker

Member
Reputation
0
iy38lh.jpg



\\CODE//
[vb]Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents txtDrives As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.txtDrives = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'txtDrives
'
Me.txtDrives.Dock = System.Windows.Forms.DockStyle.Fill
Me.txtDrives.Font = New System.Drawing.Font("Courier New", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.txtDrives.Multiline = True
Me.txtDrives.Name = "txtDrives"
Me.txtDrives.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.txtDrives.Size = New System.Drawing.Size(360, 285)
Me.txtDrives.TabIndex = 0
Me.txtDrives.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(360, 285)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtDrives})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fso As New Scripting.FileSystemObject()
Dim drv As Scripting.Drive
Dim string_builder As New System.Text.StringBuilder()

For Each drv In fso.Drives
string_builder.Append( _
drv.DriveLetter & ":" & vbCrLf & _
" Type: " & drv.DriveType.ToString() & vbCrLf)
If drv.IsReady Then
string_builder.Append( _
" File System: " & drv.FileSystem & vbCrLf & _
" Free Space: " & drv.FreeSpace & vbCrLf & _
" Total Size: " & drv.TotalSize & vbCrLf & _
" Volume Name: " & drv.VolumeName & vbCrLf & _
" Serial Number: " & drv.SerialNumber & vbCrLf & _
"--------------------" & vbCrLf)
Else
string_builder.Append( _
" Not ready" & vbCrLf & _
"--------------------" & vbCrLf)
End If
Next drv

txtDrives.Text = string_builder.ToString()
txtDrives.Select(0, 0)
End Sub
End Class
[/vb]

Or Download it From MultiUpload:
http://www.multiupload.com/FXOA9RFKMC


Credits To WhoEverSharedthesource
 
Back
Top