Rad'Val
Rad'Val

Reputation: 9241

Is there a way to delete a file/folder from a ftp server with CFNetwork?

I searched the web for a solution, but it seems that there is no easy one. Now, there must be a way of course, even if that means that I need to send the RMDIR command to the ftp myself. However my sockets/streams knowledge is not very wide and I'm not sure where should I start.

PS: Already tried CFURLDestroyResource which doesn't work for folder deletion. Apple states that CFNetwork doesn't directly support deletion for FTP scheme/protocol (only for HTTP) so I guess I have to somehow implement it myself, but again, where should I start?

Upvotes: 1

Views: 1313

Answers (2)

Deniz Mert Edincik
Deniz Mert Edincik

Reputation: 4361

First of all, CFURLDestroyResource works. The problem is, in order to delete a directory , in ftp protocol, the directory should be empty.

So basically you need to enumerate all files & directories in that directory and delete them first.

Also be careful, your URL should end with "/" if you are deleting a directory.

instead of ftp://user:[email protected]/somedir you should use ftp://user:[email protected]/somedir/

Upvotes: 4

Ben Mosher
Ben Mosher

Reputation: 13381

This open-source project supports FTP in Cocoa; however it appears it might require some hacking to make it work for Cocoa Touch.

Regardless of whether you can use it as is, the FTP protocol implementation therein may help get you on your way.

Upvotes: 0

Related Questions