0

Possible Duplicate:
What's a quick way to test to see a file exists?

I am new to iPhone development. I save an image in the "Documents" folder. Below shows the code which is using for that

NSString *fullPath=[[NSString stringWithFormat:@"Documents/%@",limgName] retain];
NSString *mpngPath = [NSHomeDirectory() stringByAppendingPathComponent:fullPath];

NSLog(@"saving path %@",mpngPath);
[myImgdata writeToFile:mpngPath atomically:YES];

My aim is the next time i want to check this image exists or not in the document folder. How to check this path exists or not.

Community
  • 1
  • 1
sai
  • 479
  • 10
  • 30

2 Answers2

3

You will have to get mpngPath the same way and later use NSFileManager to check if the file exists or not.

BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:mpngPath];
if ( fileExists ) {
    /* The image exists. Handle appropriately */
}
Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105
0

have you check by doing this:

CFShow([[NSFileManager defaultManager] directoryContentsAtPath:[NSHomeDirectory() stringByAppendingString:@"/Documents"]]);