Exemplo n.º 1
0
        private void NextUploadFileList()
        {
            var dir = this._uploadDirList[this._uploadDirIndex];

            if (!DirectoryExists(dir.UploadPath))
            {
                if (!CreateDirectory(dir.UploadPath))
                {
                    var error = new FtpException("디렉토리 생성 중 오류가 발생했습니다.");
                    RaiseUploadFileListAsyncCompleted(new FtpAsyncCompletedEventArgs(error, false));
                    return;
                }
            }

            if (dir.Files.Count > this._uploadFileIndex)
            {
                var    file       = dir.Files[this._uploadFileIndex++];
                string uploadPath = string.Format("{0}/{1}", dir.UploadPath, file.Name);

                ++this._uploadCount;

                RaiseUploadFileListChanged(new FtpUploadFileListChangedEventArgs(this._uploadTotalCount, this._uploadCount, file.Name, uploadPath));
                this._uploadFileListChangedAction(uploadPath, file.LocalPath, UploadFileCompleted);
            }
            else
            {
                this._uploadFileIndex = 0;
                ++this._uploadDirIndex;
                NextUploadFileList();
            }
        }
Exemplo n.º 2
0
        private void DownloadDirectory(string downloadPath, string localPath, DownloadDirectoryChangedAction action)
        {
            this._downloadDirIndex               = 0;
            this._downloadFileIndex              = 0;
            this._downloadTotalCount             = 0;
            this._downloadCount                  = 0;
            this._downloadDirectoryChangedAction = action;
            this._downloadLocalDirPath           = localPath;

            var rootDir = ListDirectoryDetails(downloadPath);

            if (rootDir != null)
            {
                this._downloadList = GetAllDirectories(rootDir);

                foreach (var dir in this._downloadList)
                {
                    this._downloadTotalCount += dir.Files.Count;
                }

                if (this._downloadList.Count > this._downloadDirIndex)
                {
                    var dir = this._downloadList[this._downloadDirIndex];
                    DownloadDirectory(dir);
                }
                else
                {
                    RaiseDownloadDirectoryAsyncCompleted(new FtpAsyncCompletedEventArgs(null, false));
                }
            }
            else
            {
                FtpException error = new FtpException("다운로드할 디렉토리 정보를 가져오지 못했습니다.");
                RaiseDownloadDirectoryAsyncCompleted(new FtpAsyncCompletedEventArgs(error, false));
            }
        }