Click or drag to resize

FileHelperAsyncEngineTBeginReadFile Method (String, Int32)

Open a specified file and seek to the first record.

Namespace:  FileHelpers
Assembly:  FileHelpers (in FileHelpers.dll) Version: 3.2.6
Syntax
public IDisposable BeginReadFile(
	string fileName,
	int bufferSize
)

Parameters

fileName
Type: SystemString
The file path to be read.
bufferSize
Type: SystemInt32
Buffer size to read

Return Value

Type: IDisposable
True if the file is successfully opened. False otherwise
Remarks

This method only opens the file.

To read record by record use the ReadNext method.

When you stop reading the file you must call Close method.

Examples
This example shows a simple example of use of the async methods in the FileHelperAsymcEngine:
using FileHelpers;

// First declare the record class

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


public void ReadExample()
{
    SampleType record;    

    var engine = new FileHelperAsyncEngine<SampleType>();

    using(engine.BeginReadFile("source.txt"))
    {
        foreach(var record in engine)
        {

           // put your code here !!!!
           Console.WriteLine("Data " + record.Field1 + " , " + record.Field2.ToString());

        }
    }
}
See Also