// NSString* filePath = nil;
// NSArray* folders = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// filePath = [folders objectAtIndex:0];
//
// filePath = [filePath stringByAppendingString:@"/LLW/hanlinbinnn/"];
//
// if([[NSFileManager defaultManager] fileExistsAtPath:filePath] == NO)
// {
// [[NSFileManager defaultManager] createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes: nil error:nil];
// }
//
// NSString* fileName = nil;
// NSDateFormatter* date = [[NSDateFormatter alloc] init];
// [date setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
// fileName = [date stringFromDate:[NSDate date]];
//
// fileName = [fileName stringByAppendingString:@".mov"];
// filePath = [filePath stringByAppendingString: fileName];
//
//
//
// NSLog(@"路径是:%@",filePath);
// NSLog(@"%lu",(unsigned long)datdd.length);
// [datdd writeToFile:filePath atomically:YES]; datadd就是要存的二进制(这里是视频)
这段代码演示了如何将二进制数据(视频)写入到设备的Documents目录下,创建一个以当前时间戳命名的.mov文件。首先,确定文件路径,如果目录不存在则创建,然后使用NSDateFormatter生成当前时间格式的字符串作为文件名,最后将二进制数据原子性写入到指定路径的文件中。
3113

被折叠的 条评论
为什么被折叠?



