Why not just call a command line with appropiate
net use
command - so
Process.Start
...
So here is an runnable example - just replace Server and Share with real network share:
using System.Diagnostics;
namespace MapNetworkDrive
{
class Program
{
static void Main(string[] args)
{
string strCommand = @"net use X: \\Server\Share";
Process.Start("CMD.exe", "/C \"" + strCommand + "\"");
}
}
}
So the idea is to call the commandprompt (cmd.exe) with the net use command to create the mapping. So Process.Start is used to run the commandprompt.
P.S. If you don't want to see the cmd-Window use
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
I hope this solves your Problem!