Have you tried to debug it? This is a quite simple code, debugging it might reveal, what is wrong.
You have to set
table.TableName = "SomeTableName";
and use this:
while (!reader.EndOfStream)
{
table.Rows.Add(reader.ReadLine().Split('\t'));
}
Final code:
using System.IO;
using System.Data;
namespace CSVTOXML
{
class Program
{
static void Main(string[] args)
{
string filepath = @"inputfile.csv";
StreamReader reader = new StreamReader(filepath);
string[] headers = reader.ReadLine().Split('\t');
DataTable table = new DataTable();
table.TableName = "MyTable";
foreach (string header in headers)
{
table.Columns.Add(header);
}
while (!reader.EndOfStream)
{
table.Rows.Add(reader.ReadLine().Split('\t'));
}
table.WriteXml("myoutputXML.xml",XmlWriteMode.WriteSchema, true);
}
}
}