private static void GetAllFilePaths(string folderPath, ref List <string> filePaths) { var folderStructure = new FTPFolderStructure( ftp.ReceiveData("LIST " + folderPath)); foreach (var filePath in folderStructure.GetFiles()) { filePaths.Add(folderPath + "/" + filePath); } foreach (var directory in folderStructure.GetDirectories()) { GetAllFilePaths(folderPath + "/" + directory, ref filePaths); } }
private static void DeleteFolderRecursively(string folderName) { FTPFolderStructure folderStructure = null; ftp.ExecuteCommand("CWD " + folderName); folderStructure = new FTPFolderStructure(ftp.ReceiveData("LIST")); foreach (var file in folderStructure.GetFiles()) { ftp.ExecuteCommand("DELE " + file); } foreach (var directory in folderStructure.GetDirectories()) { DeleteFolderRecursively(directory); } ftp.ExecuteCommand("CWD .."); ftp.ExecuteCommand("RMD " + folderName); }