Directory.GetFiles() not returning anything in Android build
To start, I have a simple game where players can create levels and save/load them to be edited later.
Here is how I am saving:
using (Stream stream = new FileStream(Application.persistentDataPath + @"\" + name + ".LevelData", FileMode.Create, FileAccess.Write, FileShare.None))
{
formatter.Serialize(stream, level);
}
Loading loads from the same location. However, I am trying to populate a UI dropdown with the different levels that are able to be loaded so the player can select from the saved levels instead of having to remember the names. This works when building for windows by using Directory.GetFiles() but when attempting this bit on an android device it simply returns 0 elements.
Directory.GetFiles(Application.persistentDataPath, "*" + extension, SearchOption.TopDirectoryOnly);
Does Directory.GetFiles() simply not work on Android devices, and is there another way for me to load up a list of saved levels for the player?
I found the directory that Application.persistentDataPath returns, and when I browse that location on my device, it doesn't exist. However, when I try to create a folder with the same name, it won't let me. Does anyone have any thoughts on this?
Your answer
Follow this Question
Related Questions
Reading file from StreamingAssets, Android 2 Answers
Can't get UnityWebRequest to work on android 0 Answers
Saved folders (Application.persistentDataPath) showing on Android device but not in windows explorer 2 Answers
How to access android phone files programmatically? 0 Answers
Take a Picture and Save Using Camera App 0 Answers