IOS之文件夹创建、删除,图片在本地的保存和加载
本文转自http://blog.csdn.net/toddmi/article/details/8204102
- = (NSCachesDirectory, NSUserDomainMask, YES);
- = [cachePaths objectAtIndex:0];
- }
- = (NSCachesDirectory, NSUserDomainMask, YES);
- = [cachePaths objectAtIndex:0];
- }
- = (dirName);
- = ;
- = [NSFileManager defaultManager];
- = [fileManager fileExistsAtPath:imageDir isDirectory:&isDir];
- = ;
- == YES && == YES) )
- = [fileManager createDirectoryAtPath:imageDir withIntermediateDirectories:YES attributes:nil error:nil];
- = (dirName);
- = ;
- = [NSFileManager defaultManager];
- = [fileManager fileExistsAtPath:imageDir isDirectory:&isDir];
- = ;
- == YES && == YES )
- = [fileManager removeItemAtPath:imageDir error:nil];
- = ;
- = [NSFileManager defaultManager];
- = [fileManager fileExistsAtPath:directoryPath isDirectory:&isDir];
- = ;
- == YES && == YES )
- = [UIImagePNGRepresentation(image) writeToFile:[directoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", imageName, @"png"]] options:NSAtomicWrite error:nil];
- = [UIImageJPEGRepresentation(image, 1.0) writeToFile:[directoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", imageName, @"jpg"]] options:NSAtomicWrite error:nil];
- = ;
- = [NSFileManager defaultManager];
- = [fileManager fileExistsAtPath:directoryPath isDirectory:&isDir];
- == YES && == YES )
- = [directoryPath stringByAppendingString : imageName];
- = [fileManager fileExistsAtPath:imagePath];
- = [NSData dataWithContentsOfFile : imagePath];
- = (dirName);
- = ;
- = [NSFileManager defaultManager];
- = [fileManager fileExistsAtPath:imageDir isDirectory:&isDir];
- = ;
- == YES && == YES) )
- = [fileManager createDirectoryAtPath:imageDir withIntermediateDirectories:YES attributes:nil error:nil];
- = (dirName);
- = ;
- = [NSFileManager defaultManager];
- = [fileManager fileExistsAtPath:imageDir isDirectory:&isDir];
- = ;
- == YES && == YES )
- = [fileManager removeItemAtPath:imageDir error:nil];
- = ;
- = [NSFileManager defaultManager];
- = [fileManager fileExistsAtPath:directoryPath isDirectory:&isDir];
- = ;
- == YES && == YES )
- = [UIImagePNGRepresentation(image) writeToFile:[directoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", imageName, @"png"]] options:NSAtomicWrite error:nil];
- = [UIImageJPEGRepresentation(image, 1.0) writeToFile:[directoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", imageName, @"jpg"]] options:NSAtomicWrite error:nil];
- = ;
- = [NSFileManager defaultManager];
- = [fileManager fileExistsAtPath:directoryPath isDirectory:&isDir];
- == YES && == YES )
- = [directoryPath stringByAppendingString : imageName];
- = [fileManager fileExistsAtPath:imagePath];
- = [NSData dataWithContentsOfFile : imagePath];