I have two text files in a folder, two datatables, and two tables in db. Each file goes into a datatable and eventually gets inserted into their table in the db, all that is working properly, however I am trying to set it up where if an insert fails the files don't get processed. I've been fiddling around with try catch, however I've not been able to get it to work, it seems when there is an error one the text files gets processed and populated in the table.
foreach file enumerate folder
{
if (folder path contains file1)
try
{
fill datatable
insert into database
}
catch {}
else if (folder path contains file2)
try
{
fill datatable
insert into database
}
catch {}