我在我的应用程序目录的 Documents 文件夹中创建了一个文件夹。
我想通过代码重命名该文件夹,但无法理解该怎么做。
请帮帮我。
最佳答案
你试过吗?
NString *newDirectoryName = @"<new folder name>";
NSString *oldPath = @"<path to the old folder>";
NSString *newPath = [[oldPath stringByDeletingLastPathComponent] stringByAppendingPathComponent:newDirectoryName];
NSError *error = nil;
[[NSFileManager defaultManager] moveItemAtPath:oldPath toPath:newPath error:&error];
if (error) {
NSLog(@"%@",error.localizedDescription);
// handle error
}
关于iphone - 如何重命名目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4486979/