Beispiel #1
0
        public async Task PrepareTransfer(QueueList owner)
        {
            var originalItem = this;

            //Upload
            if (_client != null && _client2 == null && finalDestinationPath.Length > 0 && isUpload &&
                FileObject is PCObjectItem)
            {
                var o = (PCObjectItem)FileObject;
                this.rootDirFtp = o.IsDirectory ? o.ClosedDirectoryInfo.Parent.FullName : o.FullSourcePath;

                //this.rootDirFtp = this.rootDirFtp.Replace("\\", "/");

                if (o.IsDirectory && o.IsValid)
                {
                    owner.GetInternalListView.Items.Remove(originalItem);
                    var allFiles = o.ClosedDirectoryInfo.GetFiles("*", SearchOption.AllDirectories).ToList()
                                   .OrderByDescending(x => x.FullName).ToList();
                    foreach (var f in allFiles)
                    {
                        if (finalDestinationPath == "/")
                        {
                            owner.AddItem(f, getUploadDirectory(f, this.rootDirFtp) + "\\" + f.Name);
                        }
                        else
                        {
                            owner.AddItem(f,
                                          finalDestinationPath + "\\" + getUploadDirectory(f, this.rootDirFtp) + "\\" + f.Name);
                        }
                    }
                }
                else if (!o.IsDirectory && o.IsValid)
                {
                    owner.GetInternalListView.Items.Remove(originalItem);
                    owner.AddItem(o.ClosedFileInfo, finalDestinationPath);
                }
            }
            //Download
            if (_client != null && _client2 == null && finalDestinationPath.Length > 0 && !isUpload &&
                FileObject is FTPObjectItem)
            {
                var o = (FTPObjectItem)FileObject;

                if (o.IsDirectory)
                {
                }
            }
        }
Beispiel #2
0
        private async Task getFilesInServerDirectory(string path, QueueList owner)
        {
            await _client.SetWorkingDirectoryAsync(path);

            foreach (var item in await _client.GetListingAsync())
            {
                if (item.Type == FtpFileSystemObjectType.Directory)
                {
                    await getFilesInServerDirectory(item.FullName, owner);
                }
                else
                {
                    owner.AddItem(item, finalDestinationPath);
                }
            }
        }