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.
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 */
}
have you check by doing this:
CFShow([[NSFileManager defaultManager] directoryContentsAtPath:[NSHomeDirectory() stringByAppendingString:@"/Documents"]]);
精彩评论