How to check if a file exists in Documents folder?
original source : https://stackoverflow.com/questions/1638834/how-to-check-if-a-file-exists-in-documents-folder
Swift 3:
let documentsURL = try! FileManager().url(for: .documentDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: true)
… gives you a file URL of the documents directory. The following checks if there’s a file named foo.html:
let fooURL = documentsURL.appendingPathComponent("foo.html")
let fileExists = FileManager().fileExists(atPath: fooURL.path)