CSV Reports
AppendToCsvFile<T>(T,String) Method
Example 



KellermanSoftware.CsvReports Namespace > CsvWriter Class > AppendToCsvFile Method : AppendToCsvFile<T>(T,String) Method
The type of the class
The value to output
The path to the output file
Append to a CSV file. For the first item passed it will create the header if OutputHeader is true.
Syntax
Public Overloads Sub AppendToCsvFile(Of T As Class)( _
   ByVal objectValue As T, _
   ByVal filePath As String _
) 
Dim instance As CsvWriter
Dim objectValue As T
Dim filePath As String
 
instance.AppendToCsvFile(Of T)(objectValue, filePath)
public void AppendToCsvFile<T>( 
   T objectValue,
   string filePath
)
where T: class
public:
void AppendToCsvFilegeneric<typename T>
( 
   T^ objectValue,
   String^ filePath
) 
where T: ref class

Parameters

objectValue
The value to output
filePath
The path to the output file

Type Parameters

T
The type of the class
Example
CsvWriter csvWriter = new CsvWriter(); //Trial Mode
//CsvWriter csvWriter = new CsvWriter("place user name here", "place license key here"); //License Mode
 
List<Person> persons = new List<Person>();
Person person1 = new Person();
person1.FirstName = "John";
person1.LastName = "Smith";
person1.BirthDate = DateTime.Now.AddYears(-6);
persons.Add(person1);
 
Person person2 = new Person();
person2.FirstName = "Sara";
person2.LastName = "Smith";
person2.BirthDate = DateTime.Now.AddYears(-4);
persons.Add(person2);
 
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testAppend.csv");
 
foreach (var person in persons)
{
    csvWriter.AppendToCsvFile(person,filePath);
}
 
Console.WriteLine(File.ReadAllText(filePath));
Dim csvWriter As New CsvWriter() 'Trial Mode
'CsvWriter csvWriter = new CsvWriter("place user name here", "place license key here"); //License Mode
 
Dim persons As New List(Of Person)()
Dim person1 As New Person()
person1.FirstName = "John"
person1.LastName = "Smith"
person1.BirthDate = Date.Now.AddYears(-6)
persons.Add(person1)
 
Dim person2 As New Person()
person2.FirstName = "Sara"
person2.LastName = "Smith"
person2.BirthDate = Date.Now.AddYears(-4)
persons.Add(person2)
 
Dim filePath As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testAppend.csv")
 
For Each person In persons
    csvWriter.AppendToCsvFile(person,filePath)
Next person
 
Console.WriteLine(File.ReadAllText(filePath))
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

CsvWriter Class
CsvWriter Members
Overload List