title: C# StreamReader ReadLine breaking lines at internal linebreaks within cells
body: <p>I have a row of data in a csv where some of the cells may contain line breaks</p>
  
  <p><a href="https://i.stack.imgur.com/lH8ef.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lH8ef.png" alt="enter image description here"></a></p>
  
  <p>I'm uploading this file using an Asp:FileUpload and trying to read through each line with a StreamReader:</p>
  
  <pre><code>var file = btnFileUpload.PostedFile;
  using (StreamReader sr = new StreamReader(file.InputStream))
  {
      string currentLine;
      var line = 1;
      // currentLine will be null when the StreamReader reaches the end of file
      while ((currentLine = sr.ReadLine()) != null)
      {
            ....do stuff...
      }
  }
  </code></pre>
  
  <p>However, in debugging I found that <code>sr.ReadLine()</code> is breaking the lines at the line breaks within the cells, such as in the Category cell. For example, when I read line 2 (the first line of data after the header), the value is:</p>
  
  <p><code>"/Home/Blog/2018/november/power,English : English,Erica Stockwell-Alpert,/Home/Blog/Categories/Accounts Payable Automation;"</code></p>
  
  <p>and then the next sr.ReadLine():</p>
  
  <p><code>"/Home/Blog/Categories/Financial Services;"</code></p>
  
  <p>and then </p>
  
  <p><code>"/Home/Blog/Categories/Robotic Process Automoation,&lt;p&gt;[the rest of the line]"</code></p>
  
  <p>How can I prevent sr.ReadLine() from breaking on the new line characters within cells? Or if I can't, how else can I read the file line by line?</p>
  
  <p>Note: I cannot use a csv reader ClassMap anad csvReader.GetRecords because the tool I am working on needs to be able to handle any different fields in the header, it is not associated with one specific class. So I need to read through the file line by line.</p>