【问题标题】:Cocoa move directories可可移动目录
【发布时间】:2011-02-04 19:55:10
【问题描述】:

如何在 cocoa 中移动目录?

每当我使用 NSFileManager 时都会出错。

NSFileManager* fileManager = [NSFileManager defaultManager];
[fileManager moveItemAtPath:[srcpath retain] toPath:[dstpath retain] error:&error];

我最终得到了错误:

nameOfDir1 无法移动到 nameOfDir2

【问题讨论】:

  • 为什么要保留这些路径?

标签: cocoa nsfilemanager


【解决方案1】:

哦,我必须在要复制到的目录之后输入要复制的目录名称。

【讨论】:

  • 是的。如果您从目标路径中省略名称,则 NSFileManager 不会暗示源目录的名称;它看到你传递了一个已经存在的目标目录并拒绝它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-10-11
  • 2011-03-14
  • 1970-01-01
  • 2021-09-09
  • 1970-01-01
  • 2022-12-10
  • 2011-09-05
相关资源
最近更新 更多