Check if file is executable

 Problem

I want to check if file, at a specific location, is executable.



 Recipe


// Create a FileManager instance

let fileManager = NSFileManager.defaultManager()

// Check if file exists, given its path

if fileManager.isExecutableFileAtPath("hello.swift") {
    print("File is executable")
} else {
    print("File is not executable")
}
				


 Playground

Find answers here

Hi there! Ask Us a Question We are ready to help