public FtpDownloadEngine (FtpEntryInfo[] source, string destination, FtpConnection connection, FtpTransferOptions opts, CopyFileProgressDialog progress_window) { initial_source = source; initial_destination = destination; this.connection = connection; this.opts = opts; progress = progress_window; thread_background = new Thread(new ThreadStart(internal_do)); update_progress_delegate_holder = new MethodInvokerUpdateProgress(update_progress); if (progress_window != null) { progress_window.FormClosing += new FormClosingEventHandler(progress_dialog_FormClosing); } transfer_progress_delegate_holder = new FtpTransferProgress(ftp_transfer_proc); }
private void show_ftp_server(mFilePanel target_panel) { var opts = Options.FtpOptions; var dialog = new FtpConnectionDialog(); dialog.FtpConnectionOptions = opts; dialog.Text = Options.GetLiteral(Options.LANG_CONNECT_TO_FTP_SERVER); if (dialog.ShowDialog() != DialogResult.OK) { return; } opts = dialog.FtpConnectionOptions; Options.FtpOptions = opts; if (!opts.Anonymous) { var user = opts.UserName; var pass = opts.Password; Messages.AskCredentials (Options.GetLiteral(Options.LANG_LOGIN_TO_FTP_SERVER), opts.ServerName, ref user, ref pass); opts.UserName = user; opts.Password = pass; } var conn = new FtpConnection(opts); var fl = new FtpDirectoryList(0, false, conn); try { fl.MainWindow = this; fl.Refill(); target_panel.Source = fl; target_panel.Refresh(); } catch (Exception ex) { Messages.ShowException(ex); } }
protected override void internal_command_proc() { QueryPanelInfoEventArgs e = new QueryPanelInfoEventArgs(); OnQueryCurrentPanel(e); if (e.FocusedIndex == -1) { return; } FtpDirectoryList ftp_list = (FtpDirectoryList)e.ItemCollection; connection = ftp_list.Connection; List <FtpEntryInfo> sels = new List <FtpEntryInfo>(); if (e.SelectedIndices.Length == 0) { sels.Add(ftp_list[e.FocusedIndex]); } else { for (int i = 0; i < e.SelectedIndices.Length; i++) { sels.Add(ftp_list[e.SelectedIndices[i]]); } } //show delete dialog DeleteFileDialog dialog = new DeleteFileDialog(); dialog.Text = "Delete files"; if (sels.Count == 1) { if (sels[0].Directory) { //dialog.labelQuestion.Text = // string.Format // ("Do you REALLY want to delete '{0}'? This directory and all its contents it will be destroyed for ever.", // FtpPath.Combine(sels[0].DirectoryPath, sels[0].EntryName)); } else { //dialog.labelQuestion.Text = // string.Format // ("Do you REALLY want to delete '{0}'? The file will be destroyed for ever.", // FtpPath.Combine(sels[0].DirectoryPath, sels[0].EntryName)); } } else { //dialog.labelQuestion.Text = // string.Format // ("Do you REALLY want to delete {0} entries? All selected files and directories with the contents will be destroyed for ever.", // sels.Count); } //dialog.checkBoxForceReadonly.Checked = false; //dialog.checkBoxForceReadonly.Enabled = false; //dialog.checkBoxSupressExceptions.Checked = false; if (dialog.ShowDialog() != DialogResult.OK) { return; } //save user selection //Options.DeleteSupressExceptions = dialog.checkBoxSupressExceptions.Checked; //supress_errors = dialog.checkBoxSupressExceptions.Checked; //and kill foreach (FtpEntryInfo info in sels) { delete_recursive(info, ftp_list.MainWindow); } if (ftp_list.MainWindow != null) { ftp_list.MainWindow.NotifyLongOperation (string.Empty, false); } e.ItemCollection.Refill(); }
private void upload_to_ftp(QueryPanelInfoEventArgs e_current, QueryPanelInfoEventArgs e_other) { DirectoryList source_directory = (DirectoryList)e_current.ItemCollection; FtpDirectoryList destination_ftp = (FtpDirectoryList)e_other.ItemCollection; List <string> source_list = new List <string>(); if (e_current.SelectedIndices.Length == 0) { if (source_directory.GetItemDisplayNameLong(e_current.FocusedIndex) == "..") { return; } source_list.Add (Path.Combine (source_directory.DirectoryPath, source_directory.GetItemDisplayNameLong(e_current.FocusedIndex))); } else { for (int i = 0; i < e_current.SelectedIndices.Length; i++) { source_list.Add (Path.Combine (source_directory.DirectoryPath, source_directory.GetItemDisplayNameLong(e_current.SelectedIndices[i]))); } } string dest_path = destination_ftp.DirectoryPath; FtpConnection ftp_conn = destination_ftp.Connection; //show upload dialog FtpTransferOptions ftp_trans_opts = Options.FtpUploadOptions; FtpTransferDialog dialog = new FtpTransferDialog(); dialog.FtpTransferOptions = ftp_trans_opts; dialog.textBoxDestination.Text = dest_path; dialog.Text = Options.GetLiteral(Options.LANG_UPLOAD); if (source_list.Count == 1) { dialog.labelSourceFile.Text = source_list[0]; } else { dialog.labelSourceFile.Text = string.Format ("{0} " + Options.GetLiteral(Options.LANG_ENTRIES), source_list.Count); } if (dialog.ShowDialog() != DialogResult.OK) { return; } //retrieve user selection ftp_trans_opts = dialog.FtpTransferOptions; dest_path = dialog.textBoxDestination.Text; //save user selection Options.FtpUploadOptions = ftp_trans_opts; //prepare progress window dialog_progress = new CopyFileProgressDialog(); dialog_progress.labelError.Visible = false; dialog_progress.labelSpeed.Text = string.Empty; dialog_progress.labelStatus.Text = string.Empty; dialog_progress.labelStatusTotal.Text = string.Empty; dialog_progress.checkBoxCloseOnFinish.Checked = Options.CopyCloseProgress; dialog_progress.TopLevel = true; int x_center = Program.MainWindow.Left + Program.MainWindow.Width / 2; int y_center = Program.MainWindow.Top + Program.MainWindow.Height / 2; int x_dialog = x_center - dialog_progress.Width / 2; int y_dialog = y_center - dialog_progress.Height / 2; if (x_dialog < 0) { x_dialog = 0; } if (x_dialog < 0) { y_dialog = 0; } dialog_progress.Show(); dialog_progress.Location = new System.Drawing.Point(x_dialog, y_dialog); //prepare upload engine FtpUploadEngine upload_engine = new FtpUploadEngine (source_list.ToArray(), dest_path, ftp_conn, ftp_trans_opts, dialog_progress); upload_engine.Done += new EventHandler(upload_engine_Done); upload_engine.UploadItemDone += new ItemEventHandler(upload_engine_UploadItemDone); upload_engine.Run(); //ftp_conn.ClearCache(dest_path); }