正在将plist文件复制到ApplicationSupport(Objective-C)中的自定义文件夹
我有一段代码,它将plist文件复制到users文件夹中的ApplicationSupport目录正在将plist文件复制到ApplicationSupport(Objective-C)中的自定义文件夹,objective-c,plist,directory,copying,Objective C,Plist,Directory,Copying,我有一段代码,它将plist文件复制到users文件夹中的ApplicationSupport目录 NSString *resourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:kAutonumberPlist]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
NSString *resourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:kAutonumberPlist];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString *dataPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:kAutonumberPlist];
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:dataPath]) {
[fileManager copyItemAtPath:resourcePath toPath:dataPath error:nil];
}
如何更改它,使其不将文件复制到~User/Library/ApplicationSupport,而是将其复制到~User/Library/ApplicationSupport/AnotherFolder。顺便说一下,“另一个文件夹”已经存在
谢谢大家! 您已经在使用stringByAppendingPathComponent-您可以再次使用它 例如:
NSString *dataPath = [[[paths objectAtIndex:0]
stringByAppendingPathComponent: @"AnotherFolder"]
stringByAppendingPathComponent: kAutonumberPlist];
您已经在使用stringByAppendingPathComponent-您可以再次使用它 例如:
NSString *dataPath = [[[paths objectAtIndex:0]
stringByAppendingPathComponent: @"AnotherFolder"]
stringByAppendingPathComponent: kAutonumberPlist];