示例#1
0
        /// <summary>
        /// 설정된 조건에 따라 원본 폴더의 모든 파일을 대상 폴더에 복사함.
        /// </summary>
        public void CopyAll()
        {
            string FolderSrc = this._RootFolderSrc;

            if (_DestType == DestTypes.FileSystem)
            {
                List <string> aDirectoryChecked = new List <string>();

                for (int i = 0, i2 = this._aRootFolderDest.Length; i < i2; i++)
                {
                    if (this._aFullPathSrc != null)
                    {
                        for (int j = 0; j < this._aFullPathSrc.Length; j++)
                        {
                            string FullPathSrc  = this._aFullPathSrc[j];
                            string FullPathDest = CPath.GetFullPathDest(FolderSrc, this._aRootFolderDest[i], FullPathSrc);

                            string FolderDest = CPath.GetFolderName(FullPathDest);
                            if (aDirectoryChecked.IndexOf(FolderDest) == -1)
                            {
                                if (!Directory.Exists(FolderDest))
                                {
                                    Directory.CreateDirectory(FolderDest);
                                }

                                aDirectoryChecked.Add(FolderDest);
                            }

                            _File.CopyFile(FullPathSrc, FullPathDest);
                        }
                    }
                    else
                    {
                        _File.CopyDirectory(FolderSrc, this._aRootFolderDest[i]);
                    }
                }
            }
            else if (_DestType == DestTypes.Ftp)
            {
                for (int i = 0, i2 = this._aFtpInfoDest.Length; i < i2; i++)
                {
                    CFtp2        FtpCur   = _aFtp[i];
                    CFtpInfoSync InfoSync = (CFtpInfoSync)FtpCur.Info;

                    List <string> aDirectoryChecked = new List <string>();

                    if (this._aFullPathSrc != null)
                    {
                        for (int j = 0; j < this._aFullPathSrc.Length; j++)
                        {
                            string FullPathSrc  = this._aFullPathSrc[j];
                            string FullPathDest = CUrl.GetFullUrlDest(FolderSrc, InfoSync.Folder, FullPathSrc);

                            string FolderDest = CUrl.GetDirectoryName(FullPathDest);
                            if (aDirectoryChecked.IndexOf(FolderDest) == -1)
                            {
                                if (!FtpCur.DirectoryExists(FolderDest))
                                {
                                    FtpCur.CreateDirectory(FolderDest);
                                }

                                aDirectoryChecked.Add(FolderDest);
                            }

                            FtpCur.UploadFile(FullPathSrc, FullPathDest);
                        }
                    }
                    else
                    {
                        FtpCur.UploadDirectory(FolderSrc, InfoSync.Folder);
                    }
                }
            }
        }