I am using ftplib for uploading files on ftp server using following code
FtpConnection ftp = new FtpConnection(serverip, ftpuser, ftppassword);
ftp.Open();
ftp.Login();
ftp.SetCurrentDirectory("domain/wwwroot");
void CreateDirOnFtp(string sDir, FtpConnection ftp)
{
try
{
foreach (string f in Directory.GetFiles(sDir))
{
Uri uri = new Uri(f);
ftp.PutFile(f, System.IO.Path.GetFileName(uri.LocalPath));
}
foreach (string d in Directory.GetDirectories(sDir))
{
string dirname = new DirectoryInfo(d).Name;
if (!ftp.DirectoryExists(dirname))
{
ftp.CreateDirectory(dirname);
}
ftp.SetCurrentDirectory(dirname);
CreateDirOnFtp(d, ftp);
}
}
catch (System.Exception e)
{
}
}
But this code is not iterating through all directories so missing some directories and files on ftp server.
so i decided to upload zip file on ftp and extract it on ftp server but I cant find any way to extract file which exist on ftp server.
How can i do this? Or any other better way to upload multiple directories and file on ftp server