- Home /
IO reading file problem
This is the script:
var sr = new StreamReader(File);
var fileContents = sr.ReadToEnd();
var lines = fileContents.Split("\n"[0]);
if (lines[0] != "Something") {
if (GUI.Button (Rect (...), lines[0])) {
...;
}
}
The Idea is that if lines[0] is equal to "Something" then nothing happens, if it says anything else, the button appears. The problem is that the button appears even if lines[0] is equal to "Something", ive also tried !== but it doesnt work either, and if i put == or ===, even if it equals "Something" nothing appears, and if i put print(lines[0]) it says "Something", i really dont know whats going on, please help me.
Answer by Owen-Reynolds · Mar 31, 2012 at 03:38 PM
You might have some slop in the file. For example, microsoft products end lines with \r\n
. Try printing out lines[i] + ") " + lines[i].Length
and checking for extra spaces or wrong lengths.
For more detail on fixing, if Length is wrong, look at the ASCII values of the extra slop:
for(int i=0;i<lines[i].Length;i++) w+=(int)(lines[i][j])+", ";
Debug.Log("Got: " + w);
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Can't get text file created by me (JavaScript) 0 Answers
C# How to read and cache text file data? 1 Answer
Problem parsing a file by group of lines 0 Answers