问题
How can I execute hidden directory and files programmatically?
i.e: .DS_Store
I want to execute all the hidden files and directories which start with the "."
Thank you for your help in advance
回答1:
Use NSFileManager
with NSDirectoryEnumerationSkipsHiddenFiles
.
For example:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *theFiles = [fileManager contentsOfDirectoryAtURL:[NSURL fileURLWithPath:@"/Users/Anne/Desktop/"]
includingPropertiesForKeys:[NSArray arrayWithObject:NSURLNameKey]
options:NSDirectoryEnumerationSkipsHiddenFiles
error:nil];
NSLog(@"%@",theFiles);
来源:https://stackoverflow.com/questions/8053820/ignore-hidden-files-and-directories-with-obj-c