我想将文档目录中的所有类型的文件复制到 ios 中的另一个目录,
if ([fileManager fileExistsAtPath:txtPath] == YES) {
[fileManager removeItemAtPath:txtPath error:&error];
}
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"txtFile" ofType:@"txt"];
[fileManager copyItemAtPath:resourcePath toPath:txtPath error:&error];
我正在使用此代码,但它仅对特定一种类型的文件有帮助。
最佳答案
在做了一些更改并从其他引用资料中找到后,我终于得到了答案,我发现这段代码非常适合我
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
filePathsArray1 = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:dataPath error:nil];
关于ios - 如何从ios中的文档目录复制不同类型的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31938123/