重命名已安装的光盘映像
下面的“源”是已安装的光盘映像 (dmg),名为“New”。我正在尝试使用 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);
The "source" below is a mounted disc image (dmg), named "New." I'm trying to rename it with a textField string and action. When I complete the action the rename fails and I am unable to eject it. The code works with standard files and folders.
Also - if I do a "Get Info" of the mounted disc image and rename it there, everything works fine.
Bottom line is I want to rename a mounted disc image using a textField string. Can someone explain?
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用磁盘仲裁框架< /a>.
You'll need to use the disk arbitration framework.