Click or drag to resize

FileHelperEngineTReadStream Method (TextReader, Int32)

Read a Stream and return an array of the contained records.

Namespace:  FileHelpers
Assembly:  FileHelpers (in FileHelpers.dll) Version: 3.2.6
Syntax
public T[] ReadStream(
	TextReader reader,
	int maxRecords
)

Parameters

reader
Type: System.IOTextReader
The reader of the source stream.
maxRecords
Type: SystemInt32
The max number of records to read. Int32.MaxValue or -1 to read all records.

Return Value

Type: T
An array of the records in the Stream

Implements

IFileHelperEngineTReadStream(TextReader, Int32)
Remarks
This method only uses the stream and does not close them after using it, you must do it.
Examples
This example shows a simple example of use of the library with a minimum of code:
using FileHelpers;

// First declare the record class

[Delimitedrecord("|")]
public class SampleType
{
    public string Field1;
    public int    Field2;
}


public void ReadExample()
{
    var engine = new FileHelperEngine<SampleType>();

    var records = engine.ReadFile("source.txt");

    // Now "records" array contains all the records in the
    // sourcefile and can be acceded like this:

    int sum = records[0].Field2 + records[1].Field2;
}
See Also