2

我正在尝试从 tmp 目录中移动一个文件,但它没有按预期工作。这是我的代码和日志:

NSFileManager *fileManager = [NSFileManager defaultManager];

NSLog(@"URL: %@", URL);

NSString *finalPath = [self fullPathForMediaDisplayType:JMediaDisplayTypeMovie];

NSLog(@"Final Path: %@", finalPath);

NSURL *finalURL = [NSURL fileURLWithPath:finalPath];

NSLog(@"Final URL: %@", finalURL);

NSError *error;
[fileManager removeItemAtURL:finalURL error:&error];
[fileManager moveItemAtURL:URL toURL:finalURL error:&error];

NSLog(@"Error: %@", error);

日志:

URL: file://localhost/private/var/mobile/Applications/APP-ID-REMOVED/tmp//trim.ptltHA.MOV
Final Path: /var/mobile/Applications/APP-ID-REMOVED/Documents/9i3bqQVsKZMXwjCr38My-movie.MOV
Final URL: file://localhost/var/mobile/Applications/APP-ID-REMOVED/Documents/9i3bqQVsKZMXwjCr38My-movie.MOV
Error: error: Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)" UserInfo=0x1f53fb30 {NSUnderlyingError=0x1f53fad0 "The operation couldn’t be completed. No such file or directory", NSFilePath=/var/mobile/Applications/APP-ID-REMOVED/Documents/9i3bqQVsKZMXwjCr38My-movie.mov, NSUserStringVariant=(
    Remove
)}

任何想法为什么这不能识别目录?文档目录肯定存在,我在里面保存了各种其他文件。

4

0 回答 0