3

下面的“源”是一个已安装的光盘映像 (dmg),名为“New”。我正在尝试使用 textField 字符串和操作重命名它。当我完成操作时,重命名失败并且我无法弹出它。该代码适用于标准文件和文件夹。

另外 - 如果我对已安装的光盘映像执行“获取信息”并在那里重命名,一切正常。

底线是我想使用 textField 字符串重命名已安装的光盘映像。有人可以解释吗?

NSString *source = [@"~/Desktop/New" stringByExpandingTildeInPath];
NSString *newFile = [input stringValue];
NSString *newPath = [[source stringByDeletingLastPathComponent] stringByAppendingPathComponent:newFile];
[[NSFileManager defaultManager] moveItemAtPath:source toPath:newPath error:NULL];
NSLog(@"File renamed to %@", newFile);
4

1 回答 1

1

您需要使用磁盘仲裁框架

于 2011-07-13T22:45:31.533 回答