Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get all mapped network drives in dropdown list

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..

like image 526
LabRat Avatar asked Oct 02 '12 11:10

LabRat


People also ask

How do I see all mapped drives?

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.

How do you view all mapped network drives CMD?

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.

Where are network drive mappings stored?

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.


1 Answers

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);
            }
        }
    }
like image 152
Michael Eakins Avatar answered Oct 05 '22 11:10

Michael Eakins