Hi,
I want to delete only EMPTY Folders in specific remote directory.
My directory structure is :
OUTBOX dir contains --> FTP dir & some files this FTp dir contains--> ABC dir & some files
I am downloading from OUTBOX using GetFiles() Recursively, when download completes i want to move these files and folders from OUTBOX to BACKUP dir.
I am able to move files only not folders so i want to delete empty folders.
I write code like this :
Ftp ftpDelete = new Ftp();
if (!ftpDelete.IsAuthenticated)
{
ftpDelete.Connect(strFtpHost, iFtpPort);
ftpDelete.Login(strFtpUsrname, strFtpPwd);
}
if (strFtpTransferMode.ToUpper().Trim() == "ACTIVE")
{
ftpDelete.Passive = false;
}
else
{
ftpDelete.Passive = true;
}
ftpDelete.Timeout = 30000;
FtpItemCollection items = ftpDelete.GetItems(new Rebex.IO.FileSet(path, "*", TraversalMode.Recursive));
if (items.Count > 0)
{
foreach (var item in items)
{
if (item.IsDirectory)
{
bool blExists = ftpDelete.DirectoryExists(item.Path);
if (blExists == true)
{
CheckAndDeleteRemoteDir(item.Path);
}
}
}
}
if (items.Count == 0)
{
ftpDelete.Delete(path, TraversalMode.Recursive);
}
But using above code i am not able to delete all empty folders.
Please help me to delete all empty folders except OUTBOX
Thanks & Regards
Srinu