简体   繁体   中英

How to create a folder structure in document folder through iTunes file sharing

I am developing application for ipad3 with file sharing through iTunes.Problem is that i can share only single file with my application.I want to add folders and sub folders to document folders. How can i add folders to document folder through iTunes file sharing?

You can create directories using NSFileManager

The method below will return the path to directory userName if it exists and create it if it doesn't.

+ (NSString *)getDocsDirectoryByUserName:(NSString *)userName 
{

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * documentDir = [paths objectAtIndex:0];
NSString * userDir = [documentDir stringByAppendingPathComponent:userName];

NSError *error;
BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:userDir 
                                         withIntermediateDirectories:YES 
                                                          attributes:nil error:&error];   

if (!success) {
    NSLog(@"Error creating data path: %@", [error localizedDescription]);
}

return userDir;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM