You do not need this. please modify as per your requirement, i am posting this again, changes as per your requirement
public static void DownloadFTPFiles(string ftpAddress, string UserName, string Password)
{
FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(ftpAddress);
try
{
reqFTP.UsePassive = true;
reqFTP.UseBinary = true;
reqFTP.KeepAlive = false;
reqFTP.Credentials = new NetworkCredential(UserName, Password);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
Stream responseStream = response.GetResponseStream();
List<string> files = new List<string>();
StreamReader reader = new StreamReader(responseStream);
while (!reader.EndOfStream)
files.Add(reader.ReadLine());
reader.Close();
responseStream.Dispose();
List<periodicalfile> lstFiles = new List<periodicalfile>();
string ftpPath = string.Empty;
foreach (var fileName in files)
{
var parentDirectory = "";
if (fileName.Contains(".zip"))
{
ftpPath = ftpAddress + fileName;
wc.Credentials = new NetworkCredential(UserName, Password);
wc.DownloadFile(file.FTPFileName, DestinationFolder + fileName);
}
else
{
parentDirectory += fileName + "/";
try
{
DownloadFTPFiles(ftpAddress + "/" + parentDirectory, UserName, Password);
}
catch (Exception ex)
{
ErrorLog.WriteLog("ftpFileProcessing", "DownloadFTPFiles(Else)", ex.Message, ex.StackTrace, "");
}
}
}
}
catch (Exception excpt)
{
reqFTP.Abort();
ErrorLog.WriteLog("ftpFileProcessing", "DownloadFTPFiles", excpt.Message, excpt.StackTrace, "");
}
}