public virtual void CreateNewDirectory(string newFilePath) { string filePath = newFilePath.Replace("\\", "/").Replace("//", "/").TrimStart('/').TrimEnd('/'); char pathSpliter = '/'; string pathBuild = string.Empty; //FileInfo fileInfo = new FileInfo(newFilePath); //string newFilePath = fileInfo.DirectoryName; if (!string.IsNullOrEmpty(DirectoryBasePath) && filePath.TrimStart('/').StartsWith(DirectoryBasePath.TrimStart('/'))) { filePath = filePath.TrimStart('/').TrimStart(DirectoryBasePath.TrimStart('/').ToCharArray()); pathBuild = DirectoryBasePath.TrimEnd('/'); } foreach (string folder in filePath.Split(pathSpliter)) { pathBuild = string.Format("{0}/{1}/", pathBuild, folder); string path = GetFtpFileTemplatePath(pathBuild); if (IsDirectoryExists(path)) { continue; } WebRequest request = WebRequest.Create(path);//"ftp://host.com/directory" request.Method = WebRequestMethods.Ftp.MakeDirectory; request.Credentials = GetFtpNetworkCredential(); using (var resp = (FtpWebResponse)request.GetResponse()) { //pathBuild = string.Format("{0}/{1}",pathBuild,folder); } } }
//private string ftpPassword; //[Durados.Config.Attributes.ColumnProperty()] //public string FtpPassword { // get // { // if (string.IsNullOrEmpty(ftpPassword)) return string.Empty; // return CipherUtility.Decrypt<AesManaged>(ftpPassword, "password", GetFtpSalt()); // } // set // { // //Available encription methods: <TripleDESCryptoServiceProvider>/<RijndaelManaged> // if (!string.IsNullOrEmpty(value)) // ftpPassword = CipherUtility.Encrypt<AesManaged>(value, "password", GetFtpSalt()); // else // ftpPassword = value; //maybe if empty do not set // } //} public virtual string GetFtpBasePath(string strFileName) { if (!string.IsNullOrEmpty(DirectoryBasePath)) { strFileName = DirectoryBasePath.Trim('/') + "/" + Path.GetFileName(strFileName); } else { strFileName = Path.GetFileName(strFileName); } // return "ftp://" + FtpHost + ":" + FtpPort.ToString() + "/"; return(strFileName); }