I’m trying to read in a username and a password. Then I want to check if that account exists, and if the password is correct. Right now I’m reading from a file which has the following layout:
Name1
Passw1
Name2
Passw2
I’m trying to read it in as follows:
using (BinaryReader bread = new BinaryReader(new FileStream (@"C:\Users\Roby\Documents\TU Delft\Minor\Unityprojects\NetworkingTest\Accounts.txt", FileMode.Open)))
{
string name = bread.ReadString();
string word = bread.ReadString();
Debug.Log(name + word);
}
I’m getting the following Exception: Failed to read past end of the stream.
So my 2 questions are:
-
How can I determine the length of the file? (How many name+passwords are there?)
-
How can I fix this exception? Right now I have 1 name and 1 password. So it should work right?