Get directory contents

 Problem

I want to get directory contents, at a specific path.



 Recipe


// Create a FileManager instance

let fileManager = NSFileManager.defaultManager()

// Get contents in directory: '.' (current one)

do {
    let files = try fileManager.contentsOfDirectoryAtPath(".")
    print(files)
}
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