c# Map Network Drive

Posted on 2013-01-19
Medium Priority
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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

741 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