Read a csv file with embedded commas

Use the TextFieldParser() class instead of String.Split() to parse csv text

 

How to create and use the TextFieldParser class
This parser handles commas in embedded quote fields better than split().

Once the line of text has been read from the file, pass it to the TextFieldParser constructor.

Set the parser properties to indicate the fields are enclosed in quotes (a requirement for reading embedded commas in a field.)

Call the parser ReadFields() to split the comma separated values line into an array of fields.
 
using Microsoft.VisualBasic.FileIO;

var parser = new TextFieldParser(new StringReader(line))
{
    HasFieldsEnclosedInQuotes = true
};

parser.SetDelimiters(",");

var dataArray = new string[] { };

while (!parser.EndOfData)
    dataArray = parser.ReadFields();

parser.Close();

 
Reference the VisualBasic assembly from your c# project
Note: You must reference the Microsoft.VisualBasic assembly in your project. Also, your csv fields that have embedded commas must be in quotes.
 

For further information, see the following:

How to read comma delimited text files