DarkWorlds
Technical User
Well I am in a bit of an issue, and I need help asap. Everything is figured out, even doing testing and it works. But when i throw it into a for loop it just dies on me.
private void Read()
{
FileStream fs = File.OpenRead(FILE_NAME);
BinaryReader br = new BinaryReader(fs);
if(File.Exists(FILE_NAME)&&fs.Length>0)
{
for(int i=0;i<members.Length;i++)
{
members.Status = br.ReadInt32();
members.Name = br.ReadString();
members.Address = br.ReadString();
members.City = br.ReadString();
members.State = br.ReadString();
members.Zip = br.ReadString();
members.Phonenumber = br.ReadString();
members.Gender = br.ReadString();
}
br.Close();
fs.Close();
}
}
Its erroring out on this statment (only when the file exisits) with the following error.
An unhandled exception of type 'System.IO.EndOfStreamException' occurred in mscorlib.dll
Additional information: Unable to read beyond the end of the stream.
Thanks for looking at this, if you need the full source of the program so you may compile it, the link is below.
private void Read()
{
FileStream fs = File.OpenRead(FILE_NAME);
BinaryReader br = new BinaryReader(fs);
if(File.Exists(FILE_NAME)&&fs.Length>0)
{
for(int i=0;i<members.Length;i++)
{
members.Status = br.ReadInt32();
members.Name = br.ReadString();
members.Address = br.ReadString();
members.City = br.ReadString();
members.State = br.ReadString();
members.Zip = br.ReadString();
members.Phonenumber = br.ReadString();
members.Gender = br.ReadString();
}
br.Close();
fs.Close();
}
}
Its erroring out on this statment (only when the file exisits) with the following error.
An unhandled exception of type 'System.IO.EndOfStreamException' occurred in mscorlib.dll
Additional information: Unable to read beyond the end of the stream.
Thanks for looking at this, if you need the full source of the program so you may compile it, the link is below.