Thursday, 5 January 2012

get the file extension of given file

hi,
    Considered as the tamil.txt file there in document folder. You want to get the file extension.
Step 1:
         First you need to get the document folder path using below code


NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [paths objectAtIndex:0];

Step 2:
      Then you need to get the exact file name path
 NSString *path=[documentDirectory stringByAppendPathComponent:@"tamil.txt"];

Step 3:
      Now you knew the exact path of file name.
then,
     NSString *fileExtension=[path pathExtension];
NSLog(@"file extension ==%@", fileExtension);

No comments:

Post a Comment