Exemple #1
0
        public static void DownloadDirectory(string localFullPath, string remoteFullPath, HostDetailModel hostDetail, ref string downloadDirLog)
        {
            if (!Directory.Exists(localFullPath))
            {
                DirectoryInfo di = Directory.CreateDirectory(localFullPath);
            }

            List <ResourceInfoModel> subDirResourceList = FTPControl.GetRemoteResourceList(remoteFullPath, hostDetail, false);

            foreach (ResourceInfoModel subDirfile in subDirResourceList)
            {
                if (subDirfile.Type == Constants.ResourceType.File)
                {
                    string localPath  = localFullPath + "\\" + subDirfile.Name;
                    string remotePath = remoteFullPath + "/" + subDirfile.Name;

                    FTPControl.DownloadFile(localPath, remotePath, hostDetail, ref downloadDirLog);
                }
            }

            foreach (ResourceInfoModel subDirfile in subDirResourceList)
            {
                if (subDirfile.Type == Constants.ResourceType.Directory)
                {
                    string localPath  = localFullPath + "\\" + subDirfile.Name;
                    string remotePath = remoteFullPath + "/" + subDirfile.Name;

                    FTPControl.DownloadDirectory(localPath, remotePath, hostDetail, ref downloadDirLog);
                }
            }
        }
Exemple #2
0
        public static void UploadDirectory(string localFullPath, string remoteFullPath, HostDetailModel hostDetail, ref string uploadDirLog)
        {
            string remoteDirName = remoteFullPath.Substring(remoteFullPath.LastIndexOf("/") + 1, remoteFullPath.Length - (remoteFullPath.LastIndexOf("/") + 1));

            if (!FTPControl.IsExistResourceName(FTPControl.GetRemoteResourceList(remoteFullPath.Substring(0, remoteFullPath.Length - (remoteDirName.Length + 1)), hostDetail, false), remoteDirName, Constants.ResourceType.Directory))
            {
                FTPControl.MakeRemoteDirectory(remoteFullPath, hostDetail);
            }

            List <ResourceInfoModel> subDirResourceList = FTPControl.GetLocalResourceList(localFullPath);

            foreach (ResourceInfoModel subDirfile in subDirResourceList)
            {
                if (subDirfile.Type == Constants.ResourceType.File)
                {
                    string localPath  = localFullPath + "\\" + subDirfile.Name;
                    string remotePath = remoteFullPath + "/" + subDirfile.Name;

                    FTPControl.UploadFile(localPath, remotePath, hostDetail, ref uploadDirLog);
                }
            }

            foreach (ResourceInfoModel subDirfile in subDirResourceList)
            {
                if (subDirfile.Type == Constants.ResourceType.Directory && subDirfile.Name != "..")
                {
                    string localPath  = localFullPath + "\\" + subDirfile.Name;
                    string remotePath = remoteFullPath + "/" + subDirfile.Name;

                    FTPControl.UploadDirectory(localPath, remotePath, hostDetail, ref uploadDirLog);
                }
            }
        }