Gathering Mapped Network Drives

  • 12 years ago

     I need to be able to gather a list of all the network drives for the current user.  I know I can do this using cmd with net use but I don't want to have to go through and parse the returning lines.  Is there a way in C# to do this?

    Thanks in advance

    Chris. 

  • 12 years ago

     I have found a solution to this problem see code below

     

     NDrive = DriveInfo.GetDrives();

     private void BuildDrives()
            {
                foreach (DriveInfo N in NDrive)
                {
                    if (N.DriveType.ToString() == "Network")
                    {
                        string dName = N.Name.ToString().Substring(0, 1);
                        MaappedDrives.Groups["MD"].Items.Add(N.ToString(), dName);
                    }
                 
                }
            }

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Every language has an optimization operator. In C++ that operator is ‘//’”