Question

How to get the file's created, modified dates and the kind of the file using NSFileHandle? please help me out with this question. i tried with NSDate, but dint find the solution.

No correct solution

OTHER TIPS

NSFileHandle is not the ideal class for this. Is there some reason you want to use that class or feel you have to?

You should use -[NSURL getResourceValue:forKey:error:] with the keys NSURLCreationDateKey, NSURLContentModificationDateKey, and NSURLTypeIdentifierKey.

If you really only have an NSFileHandle to go on, you will have to obtain its file descriptor using the -fileDescriptor method and then the fstat() function to obtain the creation and modification times. You can use fcntl() with F_GETPATH to recover the path from a file descriptor. From there, you can construct an NSURL use that to get the type (and, if you prefer, the dates, too).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top