I've been searching for ways to list all files from all directories and subdirectories using swift.
I've listed candidate solutions below that didn't work. The one method that partially worked listed all the folders in that directory but it could not list files recursively or use path expressions as below.
Here is the code that partially worked:
let filemanager:FileManager = FileManager()
let files = filemanager.enumerator(atPath: NSHomeDirectory())
while let file = files?.nextObject() {
print(file)
the limitations being
- I cannot list all the files from all the subdirectories in this directory
- I cannot specify a path like
"/User/[username]/Desktop/"
or anything else.
How can I fix this problem?
Here are links to the answers I tried but did not work