swift3.0 复制文件

前言:目的是把项目工程中的文件复制到APP的沙盒Documents路径中。


let documentsPath = NSHomeDirectory() + "/Documents/"

let fileManager = FileManager.default

//工程中的Demo文件路径

let srcUrl = Bundle.main.path(forResource: "Demo", ofType: "xml")

let isFileExit = fileManager.fileExists(atPath: srcUrl!)

if isFileExit { 

    try! fileManager.copyItem(atPath: srcUrl!, toPath: "\(documentsPath)/Demo.xml")

                

}



猜你喜欢

转载自blog.csdn.net/amberoot/article/details/79956709