Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow recursive directory removal #61

Open
intval opened this issue Aug 10, 2016 · 3 comments
Open

Allow recursive directory removal #61

intval opened this issue Aug 10, 2016 · 3 comments

Comments

@intval
Copy link

intval commented Aug 10, 2016

SftpClient.DeleteDirectory throws an exception (Permission denied) when directory contains files.
Suggestion: add support for recursive directory removal together with all the files in it, aka rm -rf dir

@claudiuconstantin
Copy link

Or at least update the documentation to clearly state that DeleteDirectory() works for empty folders only

@Blennouill
Copy link

Hello,

Could we provide a pull request to add this implementation ?

@glebov21
Copy link

glebov21 commented Feb 7, 2023

Hello,

Could we provide a pull request to add this implementation ?

foreach (SftpFile file in client.ListDirectory(path))
    {
        if ((file.Name != ".") && (file.Name != ".."))
        {
            if (file.IsDirectory)
            {
                DeleteDirectory(client, file.FullName);
            }
            else
            {
                client.DeleteFile(file.FullName);
            }
        }
    }

    client.DeleteDirectory(path);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants