Ejemplo n.º 1
0
        public void RemoveDirectory(string url)
        {
            string filename = FTPHelpers.GetFileName(url);

            if (filename == "." || filename == "..")
            {
                return;
            }

            List <FTPLineResult> files = ListDirectoryDetails(url);
            string path = FTPHelpers.GetDirectoryName(url);

            foreach (FTPLineResult file in files)
            {
                if (file.IsDirectory)
                {
                    RemoveDirectory(FTPHelpers.CombineURL(url, file.Name));
                }
                else
                {
                    DeleteFile(FTPHelpers.CombineURL(url, file.Name));
                }
            }

            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url);

            request.Proxy       = this.Options.ProxySettings;
            request.Method      = WebRequestMethods.Ftp.RemoveDirectory;
            request.Credentials = new NetworkCredential(this.Options.Account.UserName, this.Options.Account.Password);
            request.KeepAlive   = false;

            request.GetResponse();

            WriteOutput("RemoveDirectory: " + url);
        }
Ejemplo n.º 2
0
        public void DeleteDirectory(string remotePath)
        {
            Connect();

            string filename = FTPHelpers.GetFileName(remotePath);

            if (filename == "." || filename == "..")
            {
                return;
            }

            FtpItemCollection files = GetDirList(remotePath);

            foreach (FtpItem file in files)
            {
                if (file.ItemType == FtpItemType.Directory)
                {
                    DeleteDirectory(file.FullPath);
                }
                else
                {
                    DeleteFile(file.FullPath);
                }
            }

            Client.DeleteDirectory(remotePath);
        }
Ejemplo n.º 3
0
        public void DeleteFile(string url)
        {
            string filename = FTPHelpers.GetFileName(url);

            if (filename == "." || filename == "..")
            {
                return;
            }

            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(url);

            request.Proxy       = this.Options.ProxySettings;
            request.Method      = WebRequestMethods.Ftp.DeleteFile;
            request.Credentials = new NetworkCredential(this.Options.Account.UserName, this.Options.Account.Password);
            request.KeepAlive   = false;

            request.GetResponse();

            WriteOutput("DeleteFile: " + url);
        }