我正在使用CSVHelper v4.0.30319。我正在读一个日期为“//”的CSV文件。我试图覆盖DefaultTypeConverter.ConvertFromString,但它没有被调用。以下是我的代码。我该如何正确处理?
我该如何处理?
public void Reader()
{
using (var sr = new StreamReader(@"test.csv"))
{
try
{
var reader = new CsvReader(sr);
reader.Configuration.TypeConverterCache.AddConverter<DateTime?>(new DateTimeConverter());
IEnumerable<DataRecord> records = reader.GetRecords<DataRecord>();
foreach (DataRecord record in records.Take(5))
{
Debug.Print("{0} {1}, {2}, {3}", record.compid, record.standard, record.lastpmread,
record.pm_type001);
}
}
catch (Exception ex)
{
Library.WriteErrorLog(ex);
}
}
}