bool DeleteUsingStandardFtp(IActivityIOPath src)
{
FtpWebResponse response = null;
try
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ConvertSslToPlain(src.Path));
request.Method = PathIs(src) == enPathType.Directory ? WebRequestMethods.Ftp.RemoveDirectory : WebRequestMethods.Ftp.DeleteFile;
request.UseBinary = true;
request.KeepAlive = false;
request.EnableSsl = EnableSsl(src);
if(src.IsNotCertVerifiable)
{
ServicePointManager.ServerCertificateValidationCallback = AcceptAllCertifications;
}
if(src.Username != string.Empty)
{
request.Credentials = new NetworkCredential(src.Username, src.Password);
}
using(response = (FtpWebResponse)request.GetResponse())
{
if(response.StatusCode != FtpStatusCode.FileActionOK)
{
throw new Exception("Fail");
}
}
}
catch(Exception exception)
{
throw new Exception(string.Format("Could not delete {0}. Please check the path exists.", src.Path), exception);
}
finally
{
if(response != null)
{
response.Close();
}
}
return true;
}