Quick Start: Choose your file type
First, refer to the download / install page to try this on your machine.
You need to define a class that maps to the record in the source/destination file.
For this example we use this formatted file delimited by a ',':
Sample data
1732,Juan Perez,435.00,11-05-2002
554,Pedro Gomez,12342.30,06-02-2004
112,Ramiro Politti,0.00,01-02-2000
924,Pablo Ramirez,3321.30,24-11-2002
...............
Mapping Class
using FileHelpers;
[DelimitedRecord(",")]
public class Customer
{
public int CustId;
public string Name;
public decimal Balance;
[FieldConverter(ConverterKind.Date, "dd-MM-yyyy")]
public DateTime AddedDate;
}
Create a FileHelperEngine for Read and Write
var engine = new FileHelperEngine<Customer>();
// To Read Use:
var result = engine.ReadFile("FileIn.txt");
// result is now an array of Customer
// To Write Use:
engine.WriteFile("FileOut.txt", result);
Use the resulting array
foreach (Customer cust in result)
{
Console.WriteLine("Customer Info:");
Console.WriteLine(cust.Name + " - " +
cust.AddedDate.ToString("dd/MM/yy"));
}