string[] filePaths = Directory.GetFiles("D:\\", "*.csv");
foreach (var file in filePaths)
{
// string[] datacsv = System.IO.File.ReadAllLines("D:\\LP02_1506172300.csv");
string[] datacsv2 = System.IO.File.ReadAllLines(file);
string[] data_col = null;
int x = 0;
foreach (string textcsv in datacsv2)
{
data_col = textcsv.Split(',');
if (x == 0)
{
for (int i = 0; i <= data_col.Count()-1; i++)
{
Table.Columns.Add(data_col[i]);
}
x++;
}
else
{
Table.Rows.Add(data_col);
}
}
Gridviews.DataSource = Table;
this.Controls.Add(Gridviews);
错误
"Table.Columns.Add(data_col[i])" 一个名为 'Date' 的列已经属于这个 DataTable。
预先感谢