Example #1
0
        private void FTPDownload(bool openDirectory)
        {
            if (lvFTPList.SelectedItems.Count > 0)
            {
                FtpItem checkDirectory = lvFTPList.SelectedItems[0].Tag as FtpItem;

                if (openDirectory && checkDirectory != null)
                {
                    if (checkDirectory.ItemType == FtpItemType.Unknown && checkDirectory.Name == "..")
                    {
                        FTPNavigateBack();
                        return;
                    }

                    if (checkDirectory.ItemType == FtpItemType.Directory)
                    {
                        LoadDirectory(checkDirectory.FullPath);
                        return;
                    }
                }

                FolderBrowserDialog fbd = new FolderBrowserDialog();
                fbd.RootFolder = Environment.SpecialFolder.Desktop;

                if (fbd.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(fbd.SelectedPath))
                {
                    FtpItemCollection list = new FtpItemCollection();
                    foreach (ListViewItem lvi in lvFTPList.SelectedItems)
                    {
                        FtpItem file = lvi.Tag as FtpItem;
                        if (file != null)
                        {
                            list.Add(file);
                        }
                    }

                    FTPAdapter.DownloadFiles(list, fbd.SelectedPath);
                }
            }
        }