Click or drag to resize

FileHelperAsyncEngineTBeginWriteFile Method (String)

Open a file to write it. If the file exists the engine will over write it

Namespace:  FileHelpers
Assembly:  FileHelpers (in FileHelpers.dll) Version: 3.2.6
Syntax
public IDisposable BeginWriteFile(
	string fileName
)

Parameters

fileName
Type: SystemString
The file path to be opened for write.

Return Value

Type: IDisposable

[Missing <returns> documentation for "M:FileHelpers.FileHelperAsyncEngine`1.BeginWriteFile(System.String)"]

Implements

IFileHelperAsyncEngineTBeginWriteFile(String)
Remarks

When you finish writing to the file you must call the 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 WriteExample()
{
    SampleType record;    

    var engine = new FileHelperAsyncEngine<SampleType>();

    using(engine.BeginWriteFile("source.txt"))
    {
        record.Field1 = "Primer Registro";
        record.Field2 = 1;
        engine.WriteNext(record);

        record.Field1 = "Segundo Registro";
        record.Field2 = 2;
        engine.WriteNext(record);
    }

}
See Also