1.包含子路径
NSArray<NSString *> *subPaths = [manager subpathsAtPath:zipPath];
2.不包含子路径
- (NSString *)getFileName:(NSString *)zipPath {
NSString *filename = @"";
//文件操作对象
NSFileManager *manager = [NSFileManager defaultManager];
NSError *error = nil;
//不包含子路径
NSArray<NSString *> *subPaths = [manager contentsOfDirectoryAtPath:zipPath error:&error];
for (NSString *s in subPaths) {
if ([[s pathExtension] isEqualTo:@"zip"]) {//筛选出文件后缀名是zip的文件
filename = [s lastPathComponent];
break;
}
}
return filename;
}
网友评论