读书人

ios 剔除文件

发布时间: 2012-09-25 09:55:58 作者: rapoo

ios 删除文件

?

- (void)removeFileWithName:(NSString *)fileName{    // you need to write a function to get to that directory    NSString *filePath = [[self stringForDocumentDirectroy]stringByAppendingPathComponent:fileName];    NSFileManager *fileManager = [NSFileManager defaultManager];    if ([fileManager fileExistsAtPath:filePath])    {        NSError *error;        if (![fileManager removeItemAtPath:filePath error:&error])        {            NSLog(@"Error removing file: %@", error);        }        else        {            NSLog(@"successed removed file");        }    }}

?其中?[self stringForDocumentDirectroy]是document目录,

读书人网 >操作系统

热点推荐