We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

fileExistsAtPath always return false

opsl63-2
opsl63-2 asked
on
Medium Priority
2,390 Views
Last Modified: 2013-11-25
I'm trying to check if an image exists using the fileExistsAtPath method of NSFileManager :

 
Product *prod = (Product *)[products objectAtIndex:i];
					
NSFileManager *fileManager = [NSFileManager defaultManager];
		
NSString *pathForFile = prod.img_mini;
					
NSLog(@"PathForFile : %@", pathForFile);
					
if ([fileManager fileExistsAtPath:pathForFile]) 
  NSLog(@"File %@ exists !", prod.img_mini);

Open in new window


But this method always return false even if files exists in the project. Files are at the root of my project and placed in a groupe "ProductsImages". Do i have to mention this group somewhere ?

Thanks for your help.
Comment
Watch Question

fridomCEO/Programmer
CERTIFIED EXPERT

Commented:
I'd check how fileExistsAtPath: really works maybe it needs a certain kind of Path, maybe a complete path?

Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Thanks, it works. But I had a complete filename in my database. So I had to split this filename to get the extension of the file and the filename without extension. Thank you again.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.