Exemple #1
0
        public void FTPTreeCreationTest()
        {
            var ftpTreeRoot = new FTPTreeNode(FtpUri, @"ftpuser", @"mcafee!624", @"D:\Temp\FtpDownload2")
            {
                TimeOut = 5 * 1000
            };                                                                                                                   //time out in 5 seconds

            try
            {
                ftpTreeRoot.Initialize(FTPClient.ComposeInitialUriString(ftpTreeRoot.FtpUri, ftpTreeRoot.UserName, ftpTreeRoot.PassWord));
            }
            catch { }
        }
Exemple #2
0
        override public void Initialize(string uri)
        {
            base.InitializeUri(uri);

            _ftpFolder = new FTPFolder(_ftpuri.FormatFtpUri(_username, _password))
            {
                PassiveMode = false, IsBubbleUpException = _isDownload
            };

            var strFolderList = new List <string>();
            var strFileList   = new List <string>();

            _ftpFolder.ListDirectory(out strFolderList, out strFileList);

            strFileList.ForEach(fileName =>
            {
                var ftpFile = new FTPFile(_ftpuri.FormatFtpUri(_username, _password, fileName))
                {
                    PassiveMode = false, IsBubbleUpException = _isDownload
                };
                if (null != TimeOut)
                {
                    ftpFile.TimeOut = TimeOut;
                }

                _ftpFileList.Add(ftpFile);
                if (_isDownload)
                {
                    ftpFile.DownloadFile(Path.Combine(LocalFolderRoot, fileName));
                }
            });

            strFolderList.ForEach(subfolder =>
            {
                var subUri      = string.Format(@"{0}/{1}", _ftpuri, subfolder);
                var localFolder = Path.Combine(_localFolderRoot, subfolder);
                var ftpTreeNode = new FTPTreeNode(subUri,
                                                  _username,
                                                  _password,
                                                  localFolder,
                                                  IsDownload)
                {
                    PassiveMode = false, TimeOut = TimeOut
                };
                _ftpTreeNodeList.Add(ftpTreeNode);
                ftpTreeNode.Initialize(ComposeInitialUriString(subUri, _username, _password));
            });
        }