public static ConsoleProcessResult Disconnect(string strDriveLetter) { string strArguments = "use " + strDriveLetter + ": /delete"; ConsoleProcess objConsoleProcess = new ConsoleProcess(); ConsoleProcessResult objResult = objConsoleProcess.ExecuteSynchronous("net", strArguments, 10, new ConsoleProcessResultInterpreter(ProcessResultInterpreter)); return(objResult); }
public static ConsoleProcessResult Connect(string strDriveLetter, string strPath, Credentials objCredentials) { if ((strDriveLetter == null) || (strDriveLetter.Length == 0)) { throw new ArgumentOutOfRangeException("strDriveLetter", "A valid non-null, non-empty string is required."); } if ((strPath == null) || (strPath.Length == 0)) { throw new ArgumentOutOfRangeException("strPath", "A valid non-null, non-empty string is required."); } if (objCredentials == null) { throw new ArgumentNullException("objCredentials", "A valid non-null Credentials is required."); } string strArguments = "use " + strDriveLetter + ": " + strPath + " /user:"******" " + objCredentials.Password + " /persistent:no"; ConsoleProcess objConsoleProcess = new ConsoleProcess(); ConsoleProcessResult objResult = objConsoleProcess.ExecuteSynchronous("net", strArguments, 10, new ConsoleProcessResultInterpreter(ProcessResultInterpreter)); return(objResult); }