ios OBject-c判断personsArrPath文件路径是否存在数据如果存在那么删除
您可以使用NSFileManager类来判断文件路径是否存在,并使用removeItemAtPath方法来删除文件。以下是一个示例代码:
NSString *personsArrPath = @"Your file path";
// 判断文件路径是否存在
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:personsArrPath]) {
// 存在则删除文件
NSError *error;
BOOL success = [fileManager removeItemAtPath:personsArrPath error:&error];
if (success) {
NSLog(@"文件删除成功");
} else {
NSLog(@"文件删除失败: %@", error);
}
} else {
NSLog(@"文件路径不存在");
}
请确保将"Your file path"替换为您实际的文件路径
原文地址: https://www.cveoy.top/t/topic/ij8J 著作权归作者所有。请勿转载和采集!