Ok, I have 15 different csv files that I need to read, then place into XML and import their value into SQL server. I'm writing a service that uses filewatcher to see if a new file exists and take control of the process.
I'm trying to read the csv using the class from:
I'm getting an error and nothing into the class that I created to map the csv. My csv files do not have headers and they are comma delimited. I can have the data wrapped in " or not. But I cannot add headers.
I've included my basic files, but my code to read the file is as follows:
if (e.Name != null)
string thisFile = Properties.Settings.Default.watcherPath.ToString() + e.Name;
CsvFileDescription inputFileDescription = new CsvFileDescription
SeparatorChar = ',',
FirstLineHasColumnNames = false,
EnforceCsvColumnAttribute = true
CsvContext cc = new CsvContext();
IEnumerable<CornSilage> cornSil = cc.Read<CornSilage>(thisFile, inputFileDescription);
foreach (var item in cornSil)
// I want to write to xml and pass to sql server as parameter