I'm working on validating some files from our customers who have to meet a specific file format. Each line has multiple fixed length fields and ends at 511 characters with characters 512 and 513 being CR and LF.
I've been able to use a substring to get each field easily enough, but I'm having an issue with StreamReader/ReadLine locating the 512th and 513th characters. When trying to use a substring to locate those characters, I'm getting the "System.ArgumentOutofRangeException" error.
StreamReader file = new StreamReader(textBox2.Text);
while ((line = file.ReadLine()) != null)
{
int lineLength = line.Length;
string crlf = "";
/*
if (lineLength == 511)
{
crlf = line.Substring(511, 2);
}
*/
}
I've commented out the part that gives the error. What are my options to confirm the end of each line is CRLF?