PDA

View Full Version : How to know the file Type in Iphone Directory




RashiMahajan
Nov 16, 2009, 10:07 AM
HI,
In my programm
I am viewing all the files present at a location, Now i want to know the type of the file,that wether its a .png file,.jpg file,.doc or it is a folder? so that i will display a appropriate thumbnail next to it.
Is there any way to know that whether its a file/folder or which type of file in objective C.



ghayenga
Nov 16, 2009, 10:12 AM
HI,
In my programm
I am viewing all the files present at a location, Now i want to know the type of the file,that wether its a .png file,.jpg file,.doc or it is a folder? so that i will display a appropriate thumbnail next to it.
Is there any way to know that whether its a file/folder or which type of file in objective C.

Look at the NSFileManager documentation, particularly the fileAttributesAtPath method.

RashiMahajan
Nov 16, 2009, 10:44 AM
But its display "NSFileTypeDirectory" or either "NSFileTypeRegular" as file type . It display NSFileTypeRegular for all jpg/png/doc/pdf file No way to knw the extension of the files ?

sneha
Nov 16, 2009, 11:03 PM
You can read the files at the documents folder store it in some array
and then using string separator you can separate the file name and the extension.
:)

RashiMahajan
Nov 17, 2009, 12:20 AM
Thanks sneha, i was also thinking the same way bt is there any API available whcih can abstract this info also

sneha
Nov 17, 2009, 08:11 AM
They have not provided any API in the NSFileManager documentation at least. :rolleyes: