基于IOS的FTP详解(五)删除文件或者目录

来源:互联网 发布:东方财富网 mac 编辑:程序博客网 时间:2024/05/19 14:55

ftp可以通过以下方法实现删除文件的功能:

SInt32 status = 0;NSURL* url = [NSURL URLWithString:directoryStr];BOOL success = CFURLDestroyResource((__bridge CFURLRef)url, &status);if(success) {self.finishedBlock();} else {self.failBlock();}

If url uses an http scheme, an http DELETE request is sent to the resource. If url uses a file scheme, then:

  • if the reference is a file, the file is deleted;

  • if the reference is a directory and the directory is empty, the directory is deleted;

  • if the reference is a directory and the directory is not empty, the function returns false and errorCode contains kCFURLUnknownError.

如果文件夹是空的,可以实现删除功能,路径如ftp://192.168.0.1/ceshi/  后面有斜杠

我们可以通过递归来实现删除非空目录


demo地址:http://download.csdn.net/detail/junjun150013652/7629007

0 0
原创粉丝点击