?
Solved

c# Map Network Drive

Posted on 2013-01-19
3
Medium Priority
?
5,407 Views
Last Modified: 2013-01-20
Hi,

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.
0
Comment
Question by:naelyan
[X]
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
3 Comments
 
LVL 1

Accepted Solution

by:
bounty457 earned 2000 total points
ID: 38796820
Hi,
you can use this:


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

private void MapNetDrive(string driveChar, string server, string user, string password)
        
        {
            try
            {
                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;
                proc.Start();
            }
            catch (Exception e)
            {
                               MessageBox.Show(e.ToString());
             }
        }

Open in new window


Regards Bounty
0
 

Author Closing Comment

by:naelyan
ID: 38798026
Thank You
0

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