コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
        }