I have some files in my StreamingAssets folder and I am able to load them on Android as mentioned in the Unity documentation. Unity - Scripting API: Application.streamingAssetsPath
But here I need to know the filename in advance.
Now I want to get list of all the files I have added in this directory. Following code does not work on Android. It gives directory not found exception.
DirectoryInfo dir = new DirectoryInfo(Application.streamingAssetsPath);
FileInfo info = dir.GetFiles("*.*");
So I want to know how do I get list of files in my StreamingAssets folder on Android. I need the file name so I can access the filename.
Well when you read the documentation carefully you will notice:
“On Android, the files are contained
within a compressed .jar file (which
is essentially the same format as
standard zip-compressed files). This
means that if you do not use Unity’s
WWW class to retrieve the file, you
need to use additional software to see
inside the .jar archive and obtain the
So if you don’t know the direct path to a certain file you need some library that is able to handle zip files so you can look into the APK file. A quick google found this asset which seems like it should work. Though the open source SharpZipLib should also work. I’ve never tried this so i can’t say for sure.
I’m still looking for the answer myself, scouring the internet so to speak. You have to find a directory listing…but Directory methods aren’t gonna work. You need to use http as streamingAssetsPath returns a url not a file path…