I'm using the following lines below to create a connection to a shared network location, but the problem is with any connections active (I think), network.MapNetworkDrive("..")
will throw an error:
Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again.
I got pass this error by using net use * /delete
from the command line, but is there an equivalent commands in C#?
IWshNetwork_Class network = new IWshNetwork_Class();
network.MapNetworkDrive("z:", @shared_path, Type.Missing, "Admin", "!QAZxsw2");
...
network.RemoveNetworkDrive("z:");
Just Use System.Diagnostics.Process.Start("CMD.exe","/c net use * /delete /y");