示例#1
0
        public void ftp_list_sub()
        {
            string strReturn = "";

            SecureTransfer.SSHTransferProtocol Protocol = SecureTransfer.SSHTransferProtocol.SFTP;

            try {
                st = new SecureTransfer(hosts, user, password,
                                        int.Parse(port), Protocol);

                st.Connect();

                switch (Protocol)
                {
                case SecureTransfer.SSHTransferProtocol.SFTP:
                    st.asyncCallback = AsyncCallback;
                    break;
                }

                strReturn = st.List_File(dir);
            } catch (Exception ex) {
                pFrmApp.JS_Function(this.callback_error, ex.ToString());
                st?.Disconnect();
                st?.Dispose();
            }

            pFrmApp.Call_Event(callback, strReturn);
        }
示例#2
0
        public void ftp_download(
            string hosts, string user,
            string password, string port,
            string source_file, string dest_file,
            string callback_status,
            string callback_error)
        {
            this.callback_status = callback_status;
            this.callback_error  = callback_error;
            SecureTransfer.SSHTransferProtocol Protocol = SecureTransfer.SSHTransferProtocol.SFTP;

            try {
                st = new SecureTransfer(hosts, user, password,
                                        int.Parse(port), Protocol,
                                        source_file, dest_file);

                st.Connect();

                switch (Protocol)
                {
                case SecureTransfer.SSHTransferProtocol.SFTP:
                    st.asyncCallback = AsyncCallback;
                    break;
                }

                var t = new Thread(Start_Download);
                t.SetApartmentState(ApartmentState.STA);
                t.IsBackground = true;
                t.Start();
            } catch (Exception ex) {
                pFrmApp.JS_Function(this.callback_error, ex.ToString());
                st?.Disconnect();
                st?.Dispose();
            }
        }