In order to overcome this problem defined details in Schema.ini
file. if the file name is abc.txt then its need to create abc.ini file in same location.
string iniFileMsg = "[" + newfileName + ".txt]";
StreamWriter sw = new StreamWriter(newFilePath + "/schema.ini", false);
sw.WriteLine(iniFileMsg);
sw.WriteLine("Format=Delimited(|)");
sw.WriteLine("ColNameHeader=True");
sw.Flush();
If you have different coumns then its need to add as follows:
List<string> columns = excelobj.GetCSVColumnNames(excelUploadedFullPath);
// sw.WriteLine("Col1=Phone Text Width 10");
for (int i = 0; i < columns.Count; i++)
{
sw.WriteLine("Col" + (i + 1) + "=" + columns[i].Replace(" ", "_") + " Text Width 100");
}
sw.Flush();
sw.Close();
From GetCSVColumnNames() i got column names. after that i upload data as above method