示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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());
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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());
        }
示例#6
0
        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);
            }
        }