Ignore hidden files and directories with obj-c

前端 未结 1 1450
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 16:22

How can I execute hidden directory and files programmatically?

i.e: .DS_Store

I want to execute all the hidden files and direct

1条回答
  •  被撕碎了的回忆
    2021-01-12 16:32

    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);
    

    0 讨论(0)
提交回复
热议问题