I have a file in one of the folder in my documents folder .I want to create a copy of that file in some other folder with some other name.The code I am using is
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString * filePath = [NSHomeDirectory() stringByAppendingPathComponent:
[NSString stringWithFormat:@"Documents/test/test1/%@%@%@",str,currentaudioTobPlayed,@".mp3"]];
NSString * filePath2 = [NSHomeDirectory() stringByAppendingPathComponent:
[NSString stringWithFormat:@"Documents/test/test1/"]];
NSLog(@"filePat %@",filePath);
NSLog(@"filePath2 %@",filePath2);
NSLog(@"filePath2 %@",fileManager);
[fileManager copyItemAtPath:filePath toPath:filePath2 error:NULL];
[fileManager release];
But this code is not working.Please help!
In:
you’re not specifying the destination file name: ~/Documents/test/test1 is a directory.
You could do this instead: