How do I go about removing the optional field from the text field that I have output using the Filehelpers library. I'm using c#
For example, I have a shared class file with attributes such as recordnumber, filler, payment, endingspaces
Then I need to write only recordnumber and payment into the text file without the filler.
[FixedLengthRecord(FixedMode.ExactLength)]
public partial class Person
{
[FieldFixedLength(10)]
public string FirstName;
[FieldFixedLength(10)]
public string LastName;
[FieldOptional]
[FieldFixedLength(5)]
public string Optional1;
[FieldOptional]
[FieldFixedLength(5)]
public string Optional2;
[FieldOptional]
[FieldFixedLength(5)]
public string Optional3;
}
class Program
{
private static void Main(string[] args)
{
var engine = new FileHelperEngine<Person>();
Person[] allPersonRecords = GetPersonExportFromDataBase() as Person[];//This will only get the FirstName,LastName,Optional2. No result for Optional1 and Optional3
FileHelperEngine enginePerson = new FileHelperEngine(typeof(Person));
enginePerson.AppendToFile(FileName, allPersonRecords ); //Write the records to the file
//Current Output looks like this:John Lee title
//The output which I want is:John Lee title
}
}