-1

I am using FileHelpers libary and I have a pipe "|" delimited file that must have only 4 fields, and I need to validate when a record has more than 4 fields and save error.

bla|bla2|bla3|bla4 <- Good Record

bla|bla2|bla3|bla4|bla5 <- Wrong record

File Helpers throw a BadUsageException but the message does not describe well the ocurrence.

Thanks for answer.

1 Answers1

0

You can use the engine.AfterReadRecord event to tell FileHelpers to skip the record:

engine.AfterReadRecord += Engine_AfterReadRecord;

private void Engine_AfterReadRecord(EngineBase engine, FileHelpers.Events.AfterReadEventArgs<object> e)
{
    e.SkipThisRecord = true;
}

This would make the engine skip passed every record since I haven't put any criteria in. Just add your own custom logic.

netniV
  • 2,328
  • 1
  • 15
  • 24