next free drive letter

  • Thread starter Thread starter reidarT
  • Start date Start date
R

reidarT

I want to get the next free drive on computers, both local and network
drives.
reidarT
 
Dim query As ManagementObjectSearcher = New _
ManagementObjectSearcher("SELECT * From
Win32_LogicalDisk ")
Dim queryCollection As ManagementObjectCollection = query.Get()

For Each mo As ManagementObject In queryCollection

Console.WriteLine("Name: " & mo("Name").ToString() & ", type: " &
mo.Item("DriveType").ToString())

Next

if you want to get the name of potential properties you can use this code:

Dim pdc As PropertyDataCollection = mo.Properties
For Each pd As PropertyData In pdc
Console.WriteLine(pd.Name)
Next

just stick it in the above loop.
I suppose you could stick something in there to see if there is a missing
drive letter to get the next available one. You can also check to see the
type, whether is a local or network drive. I forgot the numbers but you
should be able to find them in help somewhere. You can identify a CD, a
fixed drive, a network drive, a floppy drive etc.

Hope this helps.
Steve
 

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