Reading from a text file

Hi,

I have a text file i wish to read from in unity and i have done it using

string[] lines = File.ReadAllLines(FileLocation);

This works in the editor although when the executable is made it no longer works. Is there a better way to do this?

You need to specify correct path, when running outside editor.

What is the FileLocation that works in editor?

try putting it on StreamingAssets folder

Just a note that File.ReadAllLines doesn’t work for StreamingAssets on android or webgl. You’ll need to use www instead to get the file on these platforms.