1

I need to remove files from /Library/... folder, but got an Error message:

Domain=NSCocoaErrorDomain Code=513 "%filename% couldn’t be moved to the trash because you don’t have permission to access it."

let fileManager = FileManager.default
    // Check if file exists
    if fileManager.fileExists(atPath: url.path) {
        // Delete file
        do {
            try fileManager.trashItem(at: url, resultingItemURL: nil)
        } catch let error as NSError {
            print("\(error)")
        }
    } else {
        print("File does not exist \(url.path)")
    }

How can i obtain permissions to do that? There is other ways to remove files?

casillas
  • 16,351
  • 19
  • 115
  • 215
Iurii Sm
  • 21
  • 2

0 Answers0