iPhone

[objc] File, Document directory

tenn 2013. 2. 6. 15:44




Document 디렉토리 비우기 (서브디렉토리 & 파일 지우기)



   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    

   NSArray *fileList = [filemgr subpathsAtPath:[paths objectAtIndex:0]];

        

   for(int i=0; i < fileList.count; i++){

            

            NSString *subPath = [fileList objectAtIndex:i];

            

            NSLog(@"%d : %@", i, subPath);

            

            NSString *currentPath = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0], subPath];


            [filemgr removeItemAtPath:currentPath error:NULL];

   }





파일 생성일


            NSDictionary* fileAttribs = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil];

            NSDate *result = [fileAttribs fileCreationDate]; //or fileModificationDate



http://stackoverflow.com/questions/3642013/objective-c-get-file-creation-date