views:

336

answers:

2

I'm looking for a .NET (much preferably open source in C#) library for dealing with fixed length field text files. It wouldn't be too much to write one, but existing, tested work is always nicer, to start with.

I will be extracting data in fixed length fields from files produced by a PBX. Each PBX has its own file format, as well a set of record formats. I'm looking for a library with a nice a simple way of using dynamic file and record formats, e.g. read from an INI or XML file.

EDIT: I had previously overlooked Marcos Meli' great library FileHelpers, because I thought I needed to create a class for each record type at compile time. This is not so, and the lib includes a ClassBuilder class to build classes at runtime.

NEW EDIT: Records from different PBX's differ only in layout, not in data, i.e. all the record layouts map to the same class. I'm wondering if I should use FileHelper attributes that dynamically read their start and length data from a config file?

+11  A: 

FileHelpers

Darin Dimitrov
wow... if only I knew about this earlier!
Toad
Godamnit, you could have told us about that earlier !
Clement Herreman
You could have asked :-)
Darin Dimitrov
+2  A: 

I have since been pointed to this XML based parsing code, as well as this similar project on CodeProject. The more the merrier, and the closer I will get to a 'perfect' fit.

ProfK