private func getFilePath() -> String {
NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! + "/"
}
public func changeFileName(_ newName: String,_ oldName: String) -> Bool {t
let oldFilePath = getFilePath() + oldName
let newPath = getFilePath() + newName
let url = URL(fileURLWithPath: oldFilePath)
var modifyStatus = false
do {
try FileManager.default.moveItem(at: url, to: URL(fileURLWithPath: newPath))
modifyStatus = true
} catch {
modifyStatus = false
}
return modifyStatus
}
网友评论