- Home /
Question by
yotechmobile · Mar 14, 2018 at 04:59 AM ·
streamreader
Stream Reader working in editor but not in the executable file
I am beginner on this Stream Reading but i got stuck in this...Everything is working fine inside the unity but when i create the executable file the data from the file is not shown on the screen here is my code...
public class WordParser : MonoBehaviour {
private static List<string> wordList = ReadWords();
private static List<string> ReadWords()
{
List<string> temp = new List<string>();
string Filepath = Application.dataPath + "/Resources/words.txt";
using (StreamReader sr = new StreamReader(Filepath))
{
while (!sr.EndOfStream)
temp.Add(sr.ReadLine());
}
return temp;
}
public static string GetRandomWord()
{
uint index = (uint)Random.Range(0,wordList.Count);
string randomWord = wordList[(int)index];
return randomWord;
}
}
Comment
Your answer
Follow this Question
Related Questions
Streamwriter Access violation 0 Answers
why .txt file read and write Stuck my unity android app? 1 Answer
Converting StreamWriter to StreamReader 1 Answer
FtpWebRequest and explicit ftp 0 Answers
How to streamread and parse. 0 Answers