Friday 21 June 2013

How to rename the file in document directory(Sand box)without losing of data in file?


 NString *newDirectoryName = @"<new folder name>";    
    NSString *oldPath = @"<path to the old folder>";
    NSString *newPath = [[oldPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:newDirectoryName];
    NSError *error = nil;
    [[NSFileManager defaultManager] moveItemAtPath:oldPath toPath:newPath error:&error];
    if (error) {
        NSLog(@"%@",error.localizedDescription);
        // handle error
    }

No comments:

Post a Comment