Copy file to location

 Problem

I have a file a want to copy to some specific location.



 Recipe


// Create a FileManager instance

let fileManager = NSFileManager.defaultManager()

// Copy 'hello.swift' to 'subfolder/hello.swift'

do {
    try fileManager.copyItemAtPath("hello.swift", toPath: "subfolder/hello.swift")
}
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