/// <summary> /// 지속적인 네트워크 연결 해제. /// </summary> /// <param name="Path"></param> /// <returns></returns> public static string CloseNetworkConnection(string Path) { string sResult = string.Empty; string sDir = string.Empty; Ruru.Common.OS.ConsoleUtil oConsole = null; try { oConsole = new Common.OS.ConsoleUtil(); sDir = (Path.IndexOf('$') == -1) ? Path : System.IO.Path.GetDirectoryName(Path).Trim(); sResult = oConsole.Run("cmd.exe", string.Format("/C \"NET USE \"{0}\" /delete\"", sDir)); } catch (Exception) { throw; } return(sResult); }
/// <summary> /// 지속적인 네트워크 연결 등록. /// 타 프로세스 실행 시 경로 인증을 받기 위해 PC 자체에 인증을 기록한다 (NET USE 명령어) /// </summary> /// <param name="Path">경로</param> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public static string OpenNetworkConnection(string Path, string username, string password) { string sResult = string.Empty; string sDir = string.Empty; Ruru.Common.OS.ConsoleUtil oConsole = null; try { oConsole = new Common.OS.ConsoleUtil(); sDir = (Path.IndexOf('$') == -1) ? Path : System.IO.Path.GetDirectoryName(Path).Trim(); sResult = oConsole.Run("cmd.exe", string.Format("/C \"NET USE \"{0}\" /user:{1} {2}\"", sDir, username, password)); } catch (Exception) { throw; } return sResult; }