Amazon Wish List News RSS feed. Development Blog Browse the Forums  
  Overview - Downloads - Examples - News Feed - Contact Info -

MasterDetailEngine.WriteFile Method (String, MasterDetails[], Int32)

Write the specified number of records from the array to a file.

[Visual Basic]
Overloads Public Sub WriteFile( _
   ByVal fileName As String, _
   ByVal records As MasterDetails(), _
   ByVal maxRecords As Integer _
)
[C#]
public void WriteFile(
   string fileName,
   MasterDetails[] records,
   int maxRecords
);

Parameters

fileName
The file path to be write.
records
The array of records to write.
maxRecords
The max number of array elements to write.

Return Value

True if the operation is successful. False otherwise.

Remarks

This method open, write and close the file (don't open or close the file before or after to call this method)

This method overrides existing files.

Example

You need to define a Selector Method too:

RecordAction ExampleSelector(string record)
{
   if (Char.IsLetter(record[0]))
      return RecordAction.Master;
    else
      return RecordAction.Detail;
}
                      
        
Finally you must to instanciate a MasterDetailEngine and Read/Write files:
MaterDetailEngine engine = new MaterDetailEngine(typeof(Customers), typeof(Orders), new MasterDetailSelector(ExampleSelector));

// to Read use:
MasterDetail[] res = engine.ReadFile("TestIn.txt");

// to Write use:
engine.WriteFile("TestOut.txt", res);

        

See Also

MasterDetailEngine Class | FileHelpers.MasterDetail Namespace | MasterDetailEngine.WriteFile Overload List


Powered by:

Source Forge Thanks Jetbrains for support us !! Thanks BB Software for support us !! TestDriven.NET Code Coverage by Clover.NET Code Project Article Larkware News Sharp Toolbox