FileHelperEngineTAppendToFile Method (String, T) |
Append a record to the specified file.
Namespace:
FileHelpers
Assembly:
FileHelpers (in FileHelpers.dll) Version: 3.2.6
Syntaxpublic void AppendToFile(
string fileName,
T record
)
Public Sub AppendToFile (
fileName As String,
record As T
)
Parameters
- fileName
- Type: SystemString
The file path to be written at end. - record
- Type: T
The record to write.
Return Value
Type:
True if the operation is successful. False otherwise.
Implements
IFileHelperEngineTAppendToFile(String, T)
Remarks
This method opens, seeks to the end, writes and closes the file
(don't open or close the file before or after calling this method)
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 AppendExample()
{
var engine = new FileHelperEngine<SampleType>();
SampleType[] records = new SampleType[1];
records[0] = new SampleType();
records[0].Field1 = "Hello World";
records[0].Field2 = 12;
engine.AppendToFile("destination.txt", records);
}
See Also