iphone - check if file exist -


i want check folder.if found "test.jpeg" in "path" if 's true nothing if false have download picture that

uiimage *image = [[uiimage alloc] initwithdata:[nsdata datawithcontentsofurl:[nsurl urlwithstring:[dico objectforkey:@"photo"]]]]; nomphoto = [[cell.pseudo text]stringbyreplacingoccurrencesofstring:@"\n" withstring:@""];; nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory,nsuserdomainmask,yes); nsstring *document = [paths objectatindex:0]; filename = [nsstring stringwithformat:@"%@/%@.jpeg",document,nomphoto];  nsdata *data2 = [nsdata datawithdata:uiimagejpegrepresentation(image, 0.1f)];//1.0f = 100% quality  [data2 writetofile:filename atomically:yes]; 

edit: try don't work. path good

nsstring* documentspath = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0]; nsstring* pict =  [documentspath stringbyappendingpathcomponent :@"portos"];    bool fileexists = [[nsfilemanager defaultmanager] fileexistsatpath:pict];  if (fileexists) {     nslog(@"file ok"); }else {     nslog(@"file ko"); } 

thx

its answered here.

bool fileexists = [[nsfilemanager defaultmanager] fileexistsatpath:somepath]; 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -