Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

BinaryReader floats and carriage returns

$
0
0

How do you determine while reading floats from a file using binaryreader if you have reached the end of line(carriage return)? Supposedly my binary file (.dat) contains a line of floats, then a line of strings. Before I can switch over and start reading singles I need to know where my line of floats end.

I tried reading in the floats below and converting it to string in hopes that I would be able to pull out the "\r\n" or 10 13 carriage return values but it won't work.

Any help would be much appreciated.

 

privatevoid button1_Click(object sender, EventArgs e)

{

String fileName

fileName = @"C:\myfile.dat";

FileStream fs = newFileStream(fileName, FileMode.Open);

BinaryReader r = newBinaryReader(fs);

while (r.PeekChar() > -1)

{

MessageBox.Show(r.ReadSingle().ToString());

}

 

}


Viewing all articles
Browse latest Browse all 8156


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>