login about faq

I have tried to remove directories on a sftp-server (Bitvise) via Chilkat but it fails because the directory is not empty.

I there a way, other than first remove the files in the dir, i.e. set a force flag which will remove the dir even if not empty?

I was allowed to remove the dirs when I used WINScp client.

asked Oct 10 at 07:29

chilkat's gravatar image

chilkat ♦♦
12.8k317363471


It's the server that prevents a non-empty directory from being removed. There's no way to ask the server to force the directory removal. The SFTP client must delete each of the files within the directory prior to removing.

WINScp is an application that may present the user with a "force delete" option, but under-the-covers WINScp is deleting each of the files and then deletes the directory (or so I would think). Also.. Chilkat tends to dislike providing "Methods of Mass Destruction" API calls. For example, imagine if the application passes an incorrect remote directory path to a recursive-force-remove-directory operation..

However.. it is possible to recursively delete a remote directory tree via the SyncTreeDownload method. You would use mode 99: Do not download files, but instead delete remote files that do not exist locally.

To do it, you would pass a local directory path (to SyncTreeDownload) that is empty, and then the target remote directory. After the files and sub-directories on the server are deleted, you can then delete the desired directory with the RemoveDir method.

https://www.example-code.com/csharp/sftp_synchronize_tree_download.asp

link

answered Oct 10 at 07:36

chilkat's gravatar image

chilkat ♦♦
12.8k317363471

edited Oct 10 at 07:41

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×227
×12
×2

Asked: Oct 10 at 07:29

Seen: 45 times

Last updated: Oct 10 at 07:41

powered by OSQA