private static bool CreateFTPDirectory(string directory, string folders)
{
bool exito = true;
string[] lstfolders = folders.Split('/');
string pathftp = directory;
foreach (string fol in lstfolders)
{
if (fol != "")
{
try
{
pathftp += "/" + fol;
FtpWebRequest requestDir = (FtpWebRequest)FtpWebRequest.Create(new Uri(pathftp));
requestDir.Method = WebRequestMethods.Ftp.MakeDirectory;
requestDir.Credentials = new NetworkCredential("ftpbienesraices", "b13n3sr@1c3s");
requestDir.UsePassive = true;
requestDir.UseBinary = true;
requestDir.KeepAlive = false;
FtpWebResponse response = (FtpWebResponse)requestDir.GetResponse();
Stream ftpStream = response.GetResponseStream();
ftpStream.Close();
response.Close();
}
catch (WebException ex)
{
FtpWebResponse response = (FtpWebResponse)ex.Response;
if (response.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable)
{
response.Close();
exito = true;
}
else
{
response.Close();
exito = false;
}
}
}
}
return exito;
}