c# Map Network Drive

Posted on 2013-01-19
Last Modified: 2013-01-20

I need to be able toautomatically map to a network drive using c# that includes user name and password. I'm currently using a batch file using NetUse but my customer doesn't like this solution even though it works fine.
Question by:naelyan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

bounty457 earned 500 total points
ID: 38796820
you can use this:

private void Mapping_Click(object sender, EventArgs e)
            MapNetDrive("X", @"\\\vmware", "bounty", "pass");

private void MapNetDrive(string driveChar, string server, string user, string password)
                string path = string.Format("use {0}: {1} /user:{2} {3}", driveChar, server, user, password);
                Process proc = new Process();
                proc.StartInfo.FileName = "net";
                proc.StartInfo.Arguments = path;
                proc.StartInfo.UseShellExecute = false;
            catch (Exception e)

Open in new window

Regards Bounty

Author Closing Comment

ID: 38798026
Thank You

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL ( and MongoDB (…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question