Check if file exists


I want to check if a file/folder exists at a specific location.


// Create a FileManager instance

let fileManager = NSFileManager.defaultManager()

// Check if file exists, given its path

if fileManager.fileExistsAtPath("hello.swift") {
    print("File exists")
} else {
    print("File not found")

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)