录制的音频文件不会移动?

时间:2014-11-14 05:14:45

标签: ios

我在.m4a格式的临时目录中录制了语音文件存储我希望在文档目录中移动该目录。

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"}

这是我的目标网址

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

这是我的源文件网址

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


  }

我哪里错了?

1 个答案:

答案 0 :(得分:0)

您可以将文件从源路径复制到目标路径。试试这个

 -(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);
    }


  }