Changes

Working with Directories in Objective-C

25 bytes added, 19:25, 23 April 2012
no edit summary
The createDirectoryAtURL method returns a Boolean result indicating the success or otherwise of the operation.
 
== Deleting a Directory ==
</pre>
== Getting a Directory File Listing ==
A listing of the files contained within a specified directory can be obtained using the ''directoryContentsAtpath'' contentsOfDirectoryAtPath method. This method takes the directory pathname as an argument and returns an NSArray object containing the names of the files and sub-directories in that directory:
<pre>
filemgr = [NSFileManager defaultManager];
filelist = [filemgr directoryContentsAtPathcontentsOfDirectoryAtPath: @"/tmp"error: nil];
count = [filelist count];
</pre>
When executed as part of a program, the above code excerpt will display a listing of all the files located in the ''/tmp'' directory.
== Getting the Attributes of a File or Directory ==