title: TextFieldParser Class
body: <p>I am using the <code>TextFieldParser</code> Class to read comma separated value (.csv) file. Fields in this file are enclosed with double quotes like <code>"Field1","Field2"</code>.</p>
  
  <p>So, to read file, I've set the <code>HasFieldsEnclosedInQuotes</code> property of <code>TextFieldParser</code> object to true. But I get an error of <code>MalformedLineException</code> when any of fields contain double quote (`"+ ) in the beginning. </p>
  
  <p>Example: <code>""Field2"with additional"</code> Here I should see <code>"Field2" with additional</code> as output.</p>
  
  <p>However, if <code>"</code> is anywhere except first position then it works fine. 
  Like line with <code>"Field2 "with" additional"</code> works perfectly fine and gives me <code>Field2 "with" additional</code> 
  as output.</p>
  
  <p>Does any one have same issue? Is there any way I can resolve this issue?</p>
  
  <p>This is my code:</p>
  
  <pre><code>Private Sub ReadTextFile(ByVal txtFilePath As String)
      Dim myReader As tfp = New Microsoft.VisualBasic.FileIO.TextFieldParser(txtFilePath)
      myReader.Delimiters = New String() {","}
      myReader.TextFieldType = FileIO.FieldType.Delimited
      myReader.HasFieldsEnclosedInQuotes = True
      myReader.TrimWhiteSpace = True
      Dim currentRow As String()
      Dim headerRow As Integer = 0
  
      While Not myReader.EndOfData
          Try
              currentRow = myReader.ReadFields()
  
              'Read Header
              If (headerRow = 0) Then
                 'Do work for Header Row
                  headerRow += 1
              Else
                  'Do work for Data Row
              End If
  
          Catch ex As Exception
              Dim errorline As String = myReader.ErrorLine
          End Try
      End While
  
  End Sub
  </code></pre>
  
  <p>This is my Data in csv file:</p>
  
  <pre>
  "Column1","Column2","Column3"
  "Value1","Value2",""A" Block in Building 123"
  </pre>