iphone - how to avoid overwrite file -
i using nsurlconnection download file server , storing locally follows
-(void) connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data { [webdata appenddata:data]; paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory , nsuserdomainmask, yes); self.documentsdir = [[paths objectatindex:0]stringbyappendingpathcomponent:@"newresult.zip" ]; [[nsfilemanager defaultmanager] createfileatpath:documentsdir contents:nil attributes:nil]; nsfilehandle *file1 = [nsfilehandle filehandleforupdatingatpath: documentsdir]; [file1 writedata: webdata]; [file1 closefile]; }
this working overwrite old file every time how avoid on writing know possible nsurldownload here not using nsurldownload.
if (![filemanager fileexistsatpath: path]){ nslog(@"file not exists @ path %@", path); }else{ nslog(@"file exists @ path:%@", path); }
Comments
Post a Comment