2021年3月13日 星期六

[Swift]取得檔案夾下的所有檔案名稱

透過以下方式可以取得FileManager搜尋程式中的檔案


let manager = FileManager.default

let urlForDocument = manager.urls(for: .documentDirectory, in:.userDomainMask)

let finalurl = urlForDocument.first! as URL

let contentsOfPath = try? manager.contentsOfDirectory(atPath: finalurl.path)

print("contentsOfPath: \(contentsOfPath)")




此段程式搜尋.documentDirectory,也可以搜尋程式下的.libraryDirectory

沒有留言:

張貼留言

Privacy Policy-雙五角測驗

   『 Privacy Policy 』 ichizawa built the 雙五角測驗 app as a Free app. This SERVICE is provided by ichizawa  it will not collect any of your pers...