Get attributes of file

 Problem

I want to get the attributes of a files, at given location: creation date, file type, owner, etc.



 Recipe


// Create a FileManager instance

let fileManager = NSFileManager.defaultManager()

// Get attributes of 'myfile.txt' file

do {
    let attributes = try fileManager.attributesOfItemAtPath("myfile.txt")
    print(attributes)
}
catch let error as NSError {
    print("Ooops! Something went wrong: \(error)")
}
				


 Playground

Find answers here

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