IFileHelperEngineTWriteStream Method (TextWriter, IEnumerableT, Int32) |
Write the specified number of records in the array to the Stream.
Namespace:
FileHelpers
Assembly:
FileHelpers (in FileHelpers.dll) Version: 3.2.6
Syntaxvoid WriteStream(
TextWriter writer,
IEnumerable<T> records,
int maxRecords
)
Sub WriteStream (
writer As TextWriter,
records As IEnumerable(Of T),
maxRecords As Integer
)
Parameters
- writer
- Type: System.IOTextWriter
The writer of the source stream. - records
- Type: System.Collections.GenericIEnumerableT
The records to write (Can be an array, ArrayList, etc) - maxRecords
- Type: SystemInt32
The max number of array elements to write.
Return Value
Type:
True if the operation is successful. False otherwise.
Remarks
This method only uses the stream and does not close the stream 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;
[Delimitedrecord("|")]
public class SampleType
{
public string Field1;
public int Field2;
}
public void WriteExample()
{
var engine = new FileHelperEngine<SampleType>();
SampleType[] records = new SampleType[1];
records[0] = new SampleType();
records[0].Field1 = "Hello World";
records[0].Field2 = 12;
engine.WriteFile("destination.txt", records);
}
See Also