Beispiel #1
0
        private void DownloadFile(FtpContent item)
        {
            saveFileDialog.FileName = item.Name;

            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string target = saveFileDialog.FileName;

                backgroundWorkerDownload.RunWorkerAsync(new object[] { item, target });
            }
        }
Beispiel #2
0
        private void backgroundWorkerDownload_DoWork(object sender, DoWorkEventArgs e)
        {
            FtpContent item   = (FtpContent)((object[])e.Argument)[0];
            string     target = (string)((object[])e.Argument)[1];

            if (System.IO.Path.GetFileName(target) == item.Name)
            {
                _ftp.DownloadFile(System.IO.Path.GetDirectoryName(item.Path), item.Name, System.IO.Path.GetDirectoryName(target));
            }
            else
            {
                _ftp.DownloadFile(System.IO.Path.GetDirectoryName(item.Path), item.Name, System.IO.Path.GetDirectoryName(target), System.IO.Path.GetFileName(target));
            }
        }
Beispiel #3
0
        private void lvContent_DoubleClick(object sender, EventArgs e)
        {
            if (lvContent.SelectedItems.Count == 1)
            {
                FtpContent item = (FtpContent)(lvContent.SelectedItems[0]).Tag;

                if (item.IsDirectory)
                {
                    ChangeDirectory(item.Path);
                }
                else
                {
                    DownloadFile(item);
                }
            }
        }