using System; using Microsoft.VisualBasic.FileIO; class Program { static void Main() { try { using (TextFieldParser parser = new TextFieldParser("C:\\csv.txt")) { parser.Delimiters = new string[] { "," }; while (true) { string[] parts = parser.ReadFields(); if (parts == null) { break; } Console.WriteLine("{0} field(s)", parts.Length); } } catch (&MalformedLineException ex) { throw new Exception("Malformed Line Exception in GetGenericFields at line number : " + ex.LineNumber.ToString() + "</br> with filepath :" + localPath.ToString() + "</br> and reason is :" + ex.Message.ToString() + "</br> and inner stack trace :" + ex.StackTrace.ToString()); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)