I receive following error:
“unable to read beyond the end of stream”
I write the file like this:
FileStream path = new FileStream(@"C:\Users\Moosa Raza\Desktop\byte.txt", FileMode.CreateNew);
BinaryWriter file = new BinaryWriter(path);
int a = int.Parse(Console.ReadLine());
double b = double.Parse(Console.ReadLine());
string c = Console.ReadLine();
file.Write(b);
file.Write(c);
file.Write(a);
input is a = 12, b = 13 and c = raza
Then read it like this:
FileStream path = new FileStream(@"C:\Users\Computer\Desktop\byte.txt", FileMode.Open);
BinaryReader s = new BinaryReader(path);
int a = s.ReadInt32();
double b = s.ReadDouble();
string c = s.ReadString();
Console.WriteLine("int = {0} , double = {1} , string = {2}",a,b,c);
Console.ReadKey();