Reputation: 1462
This is driving me crazy...
With this simple code I keep getting file not found on my ipad device...
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
if ([filemgr fileExistsAtPath: @"scoreCards.dgs" ] == YES)
NSLog (@"File exists");
else
NSLog (@"File not found");
Am I missing something?
Upvotes: 0
Views: 1023
Reputation: 46037
You need to get the resource file path using pathForResource:ofType:
method of NSBundle
class.
NSString *path = [[NSBundle mainBundle] pathForResource:@"scoreCards" ofType:@"dgs"];
if ([filemgr fileExistsAtPath:path ] == YES) {}
Upvotes: 3
Reputation: 69027
Assuming that your file is bundled with the app, you could use:
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"scoreCards" ofType:@"dgs"]
if ([filemgr fileExistsAtPath: filePath ] == YES)
...
Upvotes: 1