Ejemplo n.º 1
0
        protected void Setup()
        {
            _ftpFile = _ftpFileContainer.Resolve <IFTPFile>();
            _ftpFile.Initialize(FtpFileUri);

            _ftpFolder = _ftpFolderContainer.Resolve <IFTPFolder>();
            _ftpFolder.Initialize(_ftpUriConfigDetails.Uri.AbsoluteUri);
        }
Ejemplo n.º 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));
            });
        }