I have recorded voice file store in temp directory with .m4a format I want move that directory in Document Directory.
but I can not Move it I got error.
"The operation couldn’t be completed. (Cocoa error 4.)" UserInfo=0x7b660190 {NSSourceFilePathErrorKey=file:///Users/vinodjadhav/Library/Developer/CoreSimulator/Devices/067A2EAC-9987-4861-8746-97117DCE72F2/data/Containers/Data/Application/5744F8BC-4256-4010-8A14-60B228859F88/tmp/14-11-201410:32:45.m4a, NSUserStringVariant=(
Move
), NSFilePath=file:///Users/vinodjadhav/Library/Developer/CoreSimulator/Devices/067A2EAC-9987-4861-8746-97117DCE72F2/data/Containers/Data/Application/5744F8BC-4256-4010-8A14-60B228859F88/tmp/14-11-201410:32:45.m4a, NSDestinationFilePath=/Users/vinodjadhav/Library/Developer/CoreSimulator/Devices/067A2EAC-9987-4861-8746-97117DCE72F2/data/Containers/Data/Application/5744F8BC-4256-4010-8A14-60B228859F88/Documents/XpenseTag/Xpenses/sagar/823564440/audio/audio.m4a, NSUnderlyingError=0x7b660250 "The operation couldn’t be completed. No such file or directory"}
this my dest url
Dest url = /Users/vinodjadhav/Library/Developer/CoreSimulator/Devices/067A2EAC-9987-4861-8746-97117DCE72F2/data/Containers/Data/Application/5744F8BC-4256-4010-8A14-60B228859F88/Documents/XpenseTag/Xpenses/sagar/823564440/audio/audio.m4a
this my source file url
source url = file:///Users/vinodjadhav/Library/Developer/CoreSimulator/Devices/067A2EAC-9987-4861-8746-97117DCE72F2/data/Containers/Data/Application/5744F8BC-4256-4010-8A14-60B228859F88/tmp/14-11-201410:32:45.m4a
-(void)moveAudioFileFromeSource:(NSString *)sourceUrl toDest:(NSString *)destUrl
{
NSLog(@"source url = %@", sourceUrl);
NSError *Error;
if (![[NSFileManager defaultManager] moveItemAtPath:sourceUrl toPath:destUrl
error:&Error])
{
NSLog(@"Could not remove old files. Error:%@",Error);
}
}
where am I wrong?
you can copy the file from source path to your destination path . try like this
-(void)moveAudioFileFromeSource:(NSString *)sourceUrl toDest:(NSString *)destUrl
{
NSLog(@"source url = %@", sourceUrl);
NSError *Error;
if (![[NSFileManager defaultManager] copyItemAtPath:sourceUrl toPath:destUrl
error:&Error])
{
NSLog(@"Could not remove old files. Error:%@",Error);
}
}
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.