filehelpers

looking for an example of how to WRITE a masterdetail file


I would like to see a simple example of WRITING a MasterDetail file using FileHelpers.

I understand how to READ a MasterDetail file, however, I can not find an example of creating one.


Solution

  • I was able to accomplish it this way.

        var engine = new MasterDetailEngine<MyHeader,MyDetail>(); 
        var listMasterDetail = new List<MasterDetails<MyHeader,MyDetail>>();
    
        var a = new MasterDetails<MyHeader, MyDetail>();
        a.Master = headerData;
        a.Details = listDetail.ToArray();
        listMasterDetail.Add(a);
    
        engine.WriteFile(@"C:/SomeFolder/MyFile.txt", listMasterDetail);