bool UploadFile(string local_path, string remote_directory) { //BackgroundReConnector.RunWorkerAsync(); LinuxTreeViewItem.ReConnect(); try { var files = sftp.ListDirectory(remote_directory); FileInfo fi = new FileInfo(local_path); if (fi.Exists) { FileStream fs = File.Open(local_path, FileMode.Open, FileAccess.Read); sftp.UploadFile(fs, remote_directory + fi.Name); Log.Print(fi.Name + " => " + remote_directory + fi.Name, "upload file" /*, Home.m_wnd.richTextBox_status*/); LinuxTreeViewItem.current_cofile_name = fi.Name; } else { Log.PrintError("check the config file path", "upload file", Home.m_wnd.richTextBox_status); return(false); } } catch (Exception e) { Log.PrintError(e.Message, "upload file", Home.m_wnd.richTextBox_status); return(false); } return(true); }
bool UploadFile(string local_path, string remote_directory) { //LinuxTreeViewItem.ReconnectServer(); //LinuxTreeViewItem.ReConnect(); LinuxTreeViewItem.ReConnect(1000); try { FileInfo fi = new FileInfo(local_path); if (fi.Exists) { FileStream fs = File.Open(local_path, FileMode.Open, FileAccess.Read); sftp.UploadFile(fs, remote_directory + fi.Name); Log.Print(fi.Name + " => " + remote_directory + fi.Name, "upload file" /*, test4.m_wnd.richTextBox_status*/); LinuxTreeViewItem.current_cofile_name = fi.Name; fs.Close(); } else { Log.PrintError("check the config file path", "upload file", WindowMain.m_wnd.richTextBox_status); return(false); } } catch (Exception e) { Log.PrintError(e.Message, "upload file", WindowMain.m_wnd.richTextBox_status); return(false); } return(true); }
SftpFile[] PollListInDirectory() { //BackgroundReConnector.RunWorkerAsync(); LinuxTreeViewItem.ReConnect(); string local_directory = AppDomain.CurrentDomain.BaseDirectory; IEnumerable <SftpFile> files = null; try { files = sftp.ListDirectory(this.Path); } catch (Exception e) { Log.PrintError(e.Message, "load directory", Home.m_wnd.richTextBox_status); } Log.Print(this.path, "load directory" /*, Home.m_wnd.richTextBox_status*/); return(files.ToArray()); }
private static void sendCommand(string command) { //BackgroundReConnector.RunWorkerAsync(); LinuxTreeViewItem.ReConnect(); try { // send if (shell_stream != null) { shell_stream.Write(command); shell_stream.Write("\n"); shell_stream.Flush(); Log.Print(command, "send command" /*, Home.m_wnd.richTextBox_status*/); } } catch (Exception ex) { Log.PrintError(ex.Message, "send command", Home.m_wnd.richTextBox_status); } }
SftpFile[] PollListInDirectory() { //LinuxTreeViewItem.ReconnectServer(); //LinuxTreeViewItem.ReConnect(); LinuxTreeViewItem.ReConnect(1000); string local_directory = AppDomain.CurrentDomain.BaseDirectory; IEnumerable <SftpFile> files = null; try { files = sftp.ListDirectory(this.Path); } catch (Exception e) { Log.PrintError(e.Message, "load directory", WindowMain.m_wnd.richTextBox_status); } Log.Print(this.path, "load directory" /*, test4.m_wnd.richTextBox_status*/); return(files.ToArray()); }
private static void sendCommand(string command) { //LinuxTreeViewItem.ReconnectServer(); //LinuxTreeViewItem.ReConnect(); LinuxTreeViewItem.ReConnect(1000); try { // send if (shell_stream != null) { shell_stream.Write(command); shell_stream.Write("\n"); shell_stream.Flush(); Log.Print(command, "send command" /*, test4.m_wnd.richTextBox_status*/); } } catch (Exception ex) { Log.PrintError(ex.Message, "send command", WindowMain.m_wnd.richTextBox_status); } }