This is the code that works very well but need to enter the correct path as USER PROFILE : UserName
let filePathString = "file:///Users/UserName/.ssh/known_hosts"
guard let fileUrl = URL(string: "\(filePathString)") else { return }
do {
try FileManager.default.removeItem(at: fileUrl)
print("Remove successfully")
}
catch let error as NSError {
print("An error took place: \(error)")
}
How to set UserName as a variable? Thanks, everybody!
Aucun commentaire:
Enregistrer un commentaire