FileManager helper 实用方法
2022-09-18 本文已影响0人
_浅墨_
func fileInDocumentsDirectory(fileName: String) -> String {
return getDocumentsURL().appendingPathComponent(fileName).path
}
func getDocumentsURL() -> URL {
return FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last!
}
func fileExistsAtPath(path: String) -> Bool {
return FileManager.default.fileExists(atPath: fileInDocumentsDirectory(fileName: path))
}