public static void ExecuteCommand(string command, JCompDevice jd, bool remote = true) { try { Session session = Reconnect(jd, remote); //SessionOptions sessionOptions = SessionOptionsFromJCompDeviceStorage(jo, remote); //using (Session session = new Session()) //{ // Connect //session.Open(sessionOptions); //session.OutputDataReceived += Session_OutputDataReceived; CommandExecutionResult result = session.ExecuteCommand(command); result.Check(); if (result.Output != null) { Log.ProcessDebug("Result of commmand: " + result.Output); } //} } catch (SessionLocalException sle) { string errorDetail = "WinSCP: There was an error communicating with winscp process. winscp cannot be found or executed."; errorDetail += Environment.NewLine + "Message:" + sle.Message; errorDetail += Environment.NewLine + "Target Site:" + sle.TargetSite; errorDetail += Environment.NewLine + "Inner Exception:" + sle.InnerException; errorDetail += Environment.NewLine + "Stacktrace: " + sle.StackTrace; throw sle; } catch (SessionRemoteException sre) { string errorDetail = "WinSCP: Error is reported by the remote server; Local error occurs in WinSCP console session, such as error reading local file."; errorDetail += Environment.NewLine + "Message:" + sre.Message; errorDetail += Environment.NewLine + "Target Site:" + sre.TargetSite; errorDetail += Environment.NewLine + "Inner Exception:" + sre.InnerException; errorDetail += Environment.NewLine + "Stacktrace: " + sre.StackTrace; throw sre; } catch (Exception ex) { throw ex; } }