iOS - 将文件移动到视频文件夹

时间:2013-11-12 15:39:54

标签: ios objective-c nsfilemanager

我有一个应用程序,它需要一部电影,并在视频完成后将其保存到apps临时文件夹中我需要将其移动到设备上的视频文件夹....如何使用默认文件管理器完成?< / p>

我发现的源代码....如果我将文件保存在文档目录中,我可以从iPhone上的视频应用程序访问它吗?

NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *txtPath = [documentsDirectory stringByAppendingPathComponent:@"txtFile.txt"];

if ([fileManager fileExistsAtPath:txtPath] == NO) {
    NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"txtFile" ofType:@"txt"];
    [fileManager copyItemAtPath:resourcePath toPath:txtPath error:&error];
}

1 个答案:

答案 0 :(得分:1)

NSDocumentDirectory是每个iOS应用的沙盒。您要查找的API是UISaveVideoAtPathToSavedPhotosAlbum

例如:

UISaveVideoAtPathToSavedPhotosAlbum(videoPath, nil, nil, nil);