Created
April 6, 2013 21:53
-
-
Save Morse-Code/5327772 to your computer and use it in GitHub Desktop.
List contents of directory and all sub-directories.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSFileManager*fileMgr; | |
NSString*entry; | |
NSString*documentsDir; | |
NSDirectoryEnumerator*enumerator; | |
BOOL isDirectory; | |
// Create file manager | |
fileMgr =[NSFileManager defaultManager]; | |
// Path to documents directory | |
documentsDir =[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; | |
// Change to Documents directory[fileMgr changeCurrentDirectoryPath:documentsDir]; | |
// Enumerator for docs directory | |
enumerator =[fileMgr enumeratorAtPath:documentsDir]; | |
// Get each entry (file or folder)while((entry =[enumerator nextObject])!=nil){// File or directoryif([fileMgr fileExistsAtPath:entry isDirectory:&isDirectory]&& isDirectory) | |
NSLog (@"Directory - %@", entry); | |
else | |
NSLog (@" File - %@", entry); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment