Reading a text file into a DataTable
Posted on 2010-08-31
What is the easiest way to LOAD a text file into a DataTable? I have a windows form application that read in a comma delimited text file. I want to load this text file into a datatable so what is the easiest way to do this.
Here is how I am reading the text file now.
using (StreamReader sr = new StreamReader(strFileName.ToString()))
while ((line = sr.ReadLine()) != null)
Values = line.Split(Convert.ToChar(FileMapWindow.SelectedDelimiter));
I want to read this file into a DataTable dt = new DataTable() instead.