C盘下文件a.txt:
1,AB,2011.01.01
2,您好,2012.02.02
3,我在测试,2013.03.03
using FileHelpers;
using FileHelpers.DataLink;
using FileHelpers.RunTime;
namespace MySapAssist
{
public partial class FormFileHelp : DockContent
{
[DelimitedRecord(",")]
public class Customer
{
public int id;
public string name;
[FieldConverter(ConverterKind.Date, "yyyy.MM.dd")]
public DateTime birthDay;
}
private static FormFileHelp _form = null;
public static FormFileHelp Instance()
{
if (_form == null || _form.IsDisposed)
{
_form = new FormFileHelp();
}
return _form;
}
public FormFileHelp()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
FileHelperEngine engine = new FileHelperEngine(typeof(Customer));
Customer[] res = engine.ReadFile(@"c:\a.txt") as Customer[];
engine.WriteFile(@"c:\b.txt", res);
int k = 1;
}
}
嗯,感觉很简单很方便,可以使用于本地的一些缓存操作。