Using VB.Net is it possible to list all the mapped network directories/ drives in a dropdown list?
I have goggled but cant find anything useful..
To use this command, follow the steps below. Click Start, Run, type cmd, and press Enter . At the MS-DOS prompt, type net share and press Enter . Each of the shares, the location of the resource, and any remarks for that share are displayed.
On the command terminal, please then type the following: “net use”. 4 . Once this is entered, it will show you a full list of all the network drives mapped.
Mapped drives are assigned a drive letter in the registry, under HKEY_CURRENT_USER\Network. Drive letters are usually listed in upper case. However, in some circumstances, the drive letter may be placed into the registry in lower case.
To add it to a DropDownList:
Private Sub TestCase1()
Dim drive As System.IO.DriveInfo
For Each drive In System.IO.DriveInfo.GetDrives()
If drive.DriveType = IO.DriveType.Network Then
DropDownList1.Items.Add(drive.Name)
End If
Next
End Sub
This is how I would do it in C#:
private void TestCase1()
{
//Recurse through the drives on this system and add them to the new DropDownList DropDownList1 if they are a network drive.
foreach(System.IO.DriveInfo drive in System.IO.DriveInfo.GetDrives())
{
//This check ensures that drive is a network drive.
if (drive.DriveType == System.IO.DriveType.Network)
{
//If the drive is a network drive we add it here to a combobox.
DropDownList1.Items.Add(drive);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With