1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
/// <summary>
/// Disconnects a network drive
/// </summary>
/// <param name="drive">Drive (z.B. L:)</param>
private void MapNetworkDriveDisconnect(string drive)
{
Process p = new Process();
p.StartInfo.FileName = "net";
p.StartInfo.Arguments = string.Format("use {0} /DELETE", drive);
p.StartInfo.UseShellExecute = false;
p.Start();
}
/// <summary>
/// Connects a network drive
/// </summary>
/// <param name="drive">The drive letter (e.g. L:)</param>
/// <param name="server">The UNC path to the remote drive (e.g. \\MyServer\MyPrinter)</param>
/// <param name="user">The User</param>
/// <param name="password">The Password Used For Login</param>
private void MapNetworkDriveConnect(string drive, string server, string user, string password)
{
Process p = new Process();
p.StartInfo.FileName = "net";
p.StartInfo.Arguments = string.Format("use {0} {1} /user:{2} {3}", drive, server, user, password);
p.StartInfo.UseShellExecute = false;
p.Start();
}
|