Hi @RAMAN RAGAVAN ,
Thank you for the ask.
I think you just need a if condition
to check the array length + start the index from 0 instead of 1. Please see the code below. Thanks!
var pathC = @"H:\claimdetails\claims\names.txt";
string[] result = File.ReadAllLines(pathC);
DataColumn Col = table.Columns.Add("Name", typeof(String));
Col.SetOrdinal(0); // set column to first position
i = 0;
foreach (DataRow row in table.Rows)
{
if (i < result.Length)
{
row["Name"] = result[i];
i++;
}
}