3

Recently, I'm using SharpSSH to deal with remote files. The SharpSSH offers API of rmdir for removing remote directories, but I find that it throws exceptions with message "Permission denied" when the directory is not empty. Then I've got to delete each file before the final rmdir recursively, which is not efficient.

So how could I use this rmdir without the fool recursive deletion?

4

1 回答 1

3

No. In SFTP protocol, in general, there's no API to delete a folder recursively.

So even if you use another library that allows deleting a folder with a single call (like my WinSCP Session.RemoveFiles), it still internally has to recurse into subdirectories.

于 2016-11-09T10:05:12.710 回答