NSFileManager delete contents of directory
问题 How do you delete all the contents of a directory without deleting the directory itself? I want to basically empty a folder yet leave it (and the permissions) intact. 回答1: E.g. by using a directory enumerator: NSFileManager *fileManager = [[NSFileManager alloc] init]; NSDirectoryEnumerator *enumerator = [fileManager enumeratorAtPath:path]; NSString *file; while (file = [enumerator nextObject]) { NSError *error = nil; BOOL result = [fileManager removeItemAtPath:[path