我有一个应用程序可以拍摄一部电影并在视频完成后将其保存到应用程序的临时文件夹中,我需要将其移动到设备上的视频文件夹中....如何使用默认文件管理器完成此操作?
我找到的源代码....如果我将文件保存在文档目录中,我是否可以从 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];
}
最佳答案
NSDocumentDirectory
是针对每个 iOS 应用程序的沙箱。您正在查找的 API 是 UISaveVideoAtPathToSavedPhotosAlbum .
例如:
UISaveVideoAtPathToSavedPhotosAlbum(videoPath, nil, nil, nil);
关于iOS - 将文件移动到视频文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19933438/