Valid Drives

  • Thread starter Thread starter D Miller
  • Start date Start date
D

D Miller

This should be easy, but I can not figure it out, how does one get a list of
current drives on the computer?

Thanks,
David
 
David,

For 1.x or for 2.0.

In 2.0 there is a method for that.

http://msdn2.microsoft.com/en-us/library/microsoft.visualbasic.fileio.filesystem.drives.aspx

For 1.x you need some WMI code.
There are a lof of samples made for this, this is one I have saved, which
is looking at the code obviously not made by me.

\\\
Dim searcher As New ManagementObjectSearcher _
("SELECT * FROM Win32_LogicalDisk")
Dim ManObjOp As ManagementObject
If searcher.Get.Count > 1 Then
For Each ManObjOp In searcher.Get
Dim win32 As String = "Win32_LogicalDisk='" &
ManObjOp("Name").ToString & "'"
Dim ManObjLogD As New ManagementObject(win32)
For Each diskProperty As PropertyData In
ManObjLogD.Properties
If Not diskProperty.Value Is Nothing Then
Console.WriteLine _
("{0} = {1}", diskProperty.Name, diskProperty.Value)
End If
Next
Next
End If
///

I hope this helps,

Cor
 
Hi,

In addition to Cor's comments. You can use
environment.getlogicaldrives to get a list of drives on the system. You
will not get any additional information like type or size. Use the wmi for
that in the framework 1.1 or 1.0

For Each strDrive As String In Environment.GetLogicalDrives
Debug.WriteLine(strDrive)
Next


Ken
 
D Miller said:
This should be easy, but I can not figure it out, how does one get a list
of current drives on the computer?

'System.Environment.GetLogicalDrives'. This method cannot be used to check
whether or not a drive contains a disk.
 
Thanks for the command, is there any reason why it does not report back all
of network drives defined?

Thanks,
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top