To parse CSV files in C#, you can use the built-in TextFieldParser class from the Microsoft.VisualBasic.FileIO namespace. Here's an example of how to read a CSV file and print out its contents:
main.cs724 chars25 linesIn this example, we first define the path to our CSV file. Then we create a TextFieldParser object and set its properties to indicate that our CSV file is a delimited file with commas as the delimiter. We then read the file line by line using a while loop, and for each line we split it into fields using the ReadFields() method. Finally, we do something with the fields (in this case, we print them to the console), and close the TextFieldParser object when we're done.
gistlibby LogSnag