2009-11-14 27 views
0

我有这段代码,它将plist文件复制到users文件夹中的ApplicationSupport目录。将Plist文件复制到ApplicationSupport(Objective-C)中的自定义文件夹中

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]; 
    } 

如何CA改变它,这样,而不是将文件复制到〜用户/库/ ApplicationSupport,将其复制到〜用户/库/ ApplicationSupport/AnotherFolder。 “AnotherFolder”已经存在了。

谢谢!

回答

3

您已经在使用stringByAppendingPathComponent - 您可以再次使用它。

例如:

NSString *dataPath = [[[paths objectAtIndex:0] 
         stringByAppendingPathComponent: @"AnotherFolder"] 
         stringByAppendingPathComponent: kAutonumberPlist]; 
+0

谢谢您的帮助! – Michael

相关问题