public override IEnumerable <string> GetFileListFullPath(string folder = "")
 {
     foreach (FluentFTP.FtpListItem item in _client.GetListing(folder))
     {
         if (item.Type == FluentFTP.FtpFileSystemObjectType.File)
         {
             yield return(item.FullName);
         }
     }
 }
Beispiel #2
0
        private void ServerFilesTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            Boolean check = false;

            WorkingDirectory = ServerFilesTree.SelectedNode.Tag.ToString();
            foreach (FluentFTP.FtpListItem Item in FtpConnection.GetListing(WorkingDirectory))
            {
                foreach (TreeNode TestNode in ServerFilesTree.SelectedNode.Nodes)
                {
                    if (TestNode.Text == Item.FullName.Replace(WorkingDirectory + "/", ""))
                    {
                        check = true;
                        break;
                    }
                    if (TestNode.Text == Item.FullName.Replace(WorkingDirectory, ""))
                    {
                        check = true;
                        break;
                    }
                }
                if (!check)
                {
                    ServerFilesTree.SelectedNode.Nodes.Add(Item.FullName.Replace(WorkingDirectory + "/", ""));
                    ServerFilesTree.SelectedNode.LastNode.Tag = Item.FullName;
                    //MessageBox.Show("Item Name: " + ServerFilesTree.SelectedNode.LastNode.Text);
                    //MessageBox.Show("Item Tag: " + ServerFilesTree.SelectedNode.LastNode.Tag);
                }
                check = false;
            }
        }
Beispiel #3
0
 private void Button1_Click(object sender, EventArgs e)
 {
     ServerFilesTree.Nodes.Clear();
     FtpConnection                = new FluentFTP.FtpClient(HostNameTextBox.Text);
     FtpConnection.Encoding       = Encoding.UTF8;
     FtpConnection.ConnectTimeout = 10000;
     if (UsernameTextBox.Text != "")
     {
         FtpConnection.Credentials = new NetworkCredential(UsernameTextBox.Text, PasswordTextBox.Text);
     }
     try
     {
         FtpConnection.Connect();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error Connecting");
         MessageBox.Show("Error: \n " + ex.Message);
         return;
     }
     MessageBox.Show("Conected");
     WorkingDirectory = "/";
     ServerFilesTree.Nodes.Add("/");
     ServerFilesTree.Nodes[0].Tag = "/";
     foreach (FluentFTP.FtpListItem Item in FtpConnection.GetListing(WorkingDirectory))
     {
         ServerFilesTree.Nodes[0].Nodes.Add(Item.FullName.Replace(WorkingDirectory, ""));
         ServerFilesTree.Nodes[0].LastNode.Tag = Item.FullName;
         //MessageBox.Show("Item Name: " + ServerFilesTree.Nodes[0].LastNode.Text);
         //MessageBox.Show("Item Tag: " + ServerFilesTree.Nodes[0].LastNode.Tag);
     }
 }
Beispiel #4
0
        private void ProcessFolderFiles(FluentFTP.FtpClient client, String directory, Data.Models.FtpFolder parentFolder = null)
        {
            Data.Models.FtpFolder folder = null;

            lock (_locker)
                folder = folderList.FirstOrDefault(f => f.FullName == directory.Trim());

            if (folder == null)
            {
                FtpFolderService.Create(folder = new Data.Models.FtpFolder
                {
                    FullName  = directory,
                    ServerId  = Server.Id,
                    ShortName = GetDirectoryName(directory) ?? "",
                    FolderId  = parentFolder?.Id
                });
            }
            else
            {
                folder.Modified = DateTime.Now;
                folder.FolderId = parentFolder?.Id;
                FtpFolderService.Update(folder);
            }

            var list = client.GetListing(directory);

            //cannot be done in parallel some servers might be limited to 1 connection per IP
            list.ForEach((item) =>
            {
                if (item.Type == FluentFTP.FtpFileSystemObjectType.Directory)
                {
                    ProcessFolderFiles(client, item.FullName, folder);
                }
                else if (item.Type == FluentFTP.FtpFileSystemObjectType.File)
                {
                    ProcessFile(item, folder);
                }
            });
        }
Beispiel #5
0
        //TechDebt: Change interface to ICollection
        public IRemoteItem[] GetItems(string Path)
        {
            var ftpListItems = _client.GetListing(Path);
            var remoteItems  = new List <IRemoteItem>();

            foreach (var item in ftpListItems)
            {
                IRemoteItem remoteItem = null;
                if (item.Type == FluentFTP.FtpFileSystemObjectType.File)
                {
                    var remoteFile = DependencyService.Resolve <IRemoteFile>();

                    remoteFile.FullName = item.FullName;
                    remoteFile.Name     = item.Name;

                    remoteItem = remoteFile;
                }
                else if (item.Type == FluentFTP.FtpFileSystemObjectType.Directory)
                {
                    var remoteDirectory = DependencyService.Resolve <IRemoteDirectory>();

                    remoteDirectory.FullName = item.FullName;
                    remoteDirectory.Name     = item.Name;

                    remoteItem = remoteDirectory;
                }
                else
                {
                    continue;
                }

                remoteItems.Add(remoteItem);
            }

            return(remoteItems.ToArray());
        }