写入文件

+ (NSString*)getPathByFileName:(NSString *)_fileName ofType:(NSString *)_type

{

    NSString* fileDirectory = [[[VoiceRecorderBaseVCgetCacheDirectory]stringByAppendingPathComponent:_fileName]stringByAppendingPathExtension:_type];

    return fileDirectory;

}

+ (NSString*)getCurrentTimeString

{

    NSDateFormatter *dateformat=[[[NSDateFormatter  alloc]init]autorelease];

    [dateformat setDateFormat:@"yyyyMMddHHmmss"];

    return [dateformat stringFromDate:[NSDate date]];

}

-(void)writeJPGToFile:(ChatMessageInfo *)_info

{

    NSData *imageData = [NSDatadataWithContentsOfURL:[NSURLURLWithString:_info.networkPath]];

    NSString *fileName = [ChatVoiceRecorderVC getCurrentTimeString];

    NSString *localFilePath = [ChatVoiceRecorderVC getPathByFileName:fileName ofType:@"jpg"];

    [imageData writeToFile:localFilePath atomically:NO];

    _info.localPath = localFilePath;

    

}

posted @ 2014-01-24 14:34  路在脚下,  阅读(274)  评论(0编辑  收藏  举报