开发者

how to chech image is existing in the folder [duplicate]

开发者 https://www.devze.com 2023-03-20 03:11 出处:网络
This question already has an answer开发者_运维技巧 here: Closed 11 years ago. Possible Duplicate:
This question already has an answer开发者_运维技巧 here: Closed 11 years ago.

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"]]);

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号