Processing fixed length or delimited files quickly and easily in .NET

I recently ran into a really useful Open Source project called FileHelpers by Marcos Meli. FileHelpers is a .NET library used to import and export data to/from fixed length or delimited text files. The library is highly customizable with good documentation, lots of examples and a record class wizard to help you build classes that match your data.

FileHelpers record class wizard screenshot

It even supports master detail as well as multi-record mappings making it easy to work with all sorts of structured flat file data.

I’ve been working on a large ERP system and I’m currently focused on adding support for EDI Invoicing. EDI is a set of standards for structuring data that’s passed electronically between trading partners. EDI files are structured plain text files and I’m currently investigating FileHelpers MultiRecordEngine class for use with producing and consuming EDI files. I’ve only spent a few hours so far and I already have basic reading and writing of EDI 810 Invoices working.

One thing I did want to mention is that the example on the site for hooking up events is incorrect so here is an example of subscribing to the AfterWriteRecord event:

m_engine = new MultiRecordEngine(GetSelector(), GetRecordTypes()); m_engine.AfterWriteRecord += new EventHandler<AfterWriteRecordEventArgs<object>>(AfterWriteRecord); private void AfterWriteRecord(object sender, AfterWriteRecordEventArgs<object> e) { ... }

2 thoughts on “Processing fixed length or delimited files quickly and easily in .NET

Comments are closed.