Search code examples
iphonefileinfo

How to access file info (such as date created,size etc) about a file in iphone?


How to access file info (such as date created,size etc) about a file in iphone?i need to sort certain files based on the date of creation,size etc..


Solution

  • Try this method:

    NSError *error;
    NSDictionary* attributes = [[NSFileManager defaultManager] 
                                 attributesOfItemAtPath: filePath 
                                                  error: &error];
    

    You can then query [attributes fileCreationDate] or [attributes fileSize]. See NSFileManager.h for the NSFileAttributes category of NSDictionary.