/*________保存图片到沙河路径文件夹_____________**littleSun_zheng**/
//先把图片转成NSDataNSData*data =UIImageJPEGRepresentation(image,.000000005);
//文件管理器NSFileManager*fileManager = [NSFileManagerdefaultManager];
//拼接要存放东西的文件夹NSString*pathDocuments = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)objectAtIndex:0];
NSString*createPath = [NSStringstringWithFormat:@"%@/EcmChatMyPic", pathDocuments];
//判断文件夹是否存在,如果不存在,则创建if(![[NSFileManagerdefaultManager]fileExistsAtPath:createPath])
{
//如果没有就创建这个 想创建的文件夹 ()
[fileManager
createDirectoryAtPath:createPathwithIntermediateDirectories:YESattributes:nilerror:nil];
//然后保存
NSString* DocumentsPath = [NSHomeDirectory()stringByAppendingPathComponent:@"Documents/EcmChatMyPic"];
NSString*imgFileName = [NSStringstringWithFormat:@"/%@.jpg",fileName];
[fileManager
createFileAtPath:[DocumentsPath stringByAppendingString:imgFileName]contents:data attributes:nil];
}
else{//文件夹存在 直接保存NSString* DocumentsPath = [NSHomeDirectory()stringByAppendingPathComponent:@"Documents/EcmChatMyPic"];
NSString*imgFileName = [NSStringstringWithFormat:@"/%@.jpg",fileName];
[fileManager
createFileAtPath:[DocumentsPath stringByAppendingString:imgFileName]contents:data attributes:nil];
}
//存完之后 接着就取出来 发送NSString* DocumentsPath = [NSHomeDirectory()stringByAppendingPathComponent:@"Documents/EcmChatMyPic"];
NSString*imgFileName = [NSStringstringWithFormat:@"/%@.jpg",fileName];
NSString* filePath = [[NSString alloc] initWithFormat:@"%@%@",DocumentsPath,imgFileName];
//取出图片 等待 你的使用
UIImage*img = [UIImage imageWithContentsOfFile:filePath];