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
Post a Comment