How can I load a text file on Android?

I’m using this code in my iOS project to load text files and it’s working. But on Android the code isn’t working. I want to load a text file(File.txt) but I get this error message. I set the build action of File.txt to “Content”. The file is located in my Android project’s directory.

System.IO.Stream stream = TitleContainer.OpenStream(filename);

System.IO.FileNotFoundException has been thrown File.txt

edit: The file needs to be in the Assets folder and build action on AndroidAsset. Then it works.

1 Like