title: C# Determine EOL Character in flat files
body: <p>I am attempting to identify what the EOL character is from a given .txt or .csv flat file. Based on what the EOL character is from the first row of data in the flat file, I want to process the data from this file accordingly (I am using Bulk Load to create tables on SQL Server and need to pass in the EOL to the bulk load command). From what I understand, Readline() handles the EOL automatically, so I can't parse the Readline() string for the EOL character. The code below gives an example of what I am trying to do:</p>
  
  <pre><code>int EOLChar_CRLF = 0;
  int EOLChar_LF = 0;
  int EOLChar_CR = 0;
  int EOLChar_Hex = 0;
  
  string eol_line = file2.ReadLine();
  MessageBox.Show(eol_line);
  EOLChar_CRLF = eol_line.IndexOf("\\r\\\n");
  EOLChar_LF = eol_line.IndexOf("\\n");
  EOLChar_CR = eol_line.IndexOf("\\r");
  EOLChar_Hex = eol_line.IndexOf("\\0x0a");
  
  MessageBox.Show("CRLF is line feed if " + EOLChar_CRLF.ToString() + " &lt;&gt; -1");
  MessageBox.Show("LF is line feed if " + EOLChar_LF.ToString() + " &lt;&gt; -1");
  MessageBox.Show("CR is line feed if " + EOLChar_CR.ToString() + " &lt;&gt; -1");
  MessageBox.Show("0x0a is line feed if " + EOLChar_Hex.ToString() + " &lt;&gt; -1");
  </code></pre>
  
  <p>Does anybody know of a way to determine the EOL using the StreamReader.ReadLine() method or any other way of accomplishing this? I only want to read in the first row of data and parse that for the EOL since some of these files are 20+ million rows.</p>