我正在使用 File Helpers 2.9.9 我想知道如何让它跳过坏记录而不是崩溃?
object[] transactions = engine.ReadStream(textReader); // will crash if one record fails.
我也遇到了 DateTime 的问题。我不明白为什么它不能使用我设置的格式转换“12/22/2011”。
Error Converting '"12/22/2011"' to type: 'DateTime'. does not match any of the given formats: 'MM/dd/yyyy', 'MM/d/yyyy', 'M/d/yyyy'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: FileHelpers.ConvertException: Error Converting '"12/22/2011"' to type: 'DateTime'. does not match any of the given formats: 'MM/dd/yyyy', 'MM/d/yyyy', 'M/d/yyyy'
最佳答案
1) [EDIT] - 我错了,您可以将 engine.ErrorManager.ErrorMode 设置为 SaveAndContinue - 请参阅示例 @ http://www.filehelpers.com/example_errorhandling.html
2) 基于包含带双引号的字符串的单引号,我会说问题是您需要提供 FieldQuoted 属性 - 请参阅 http://www.filehelpers.com/attributes.html
关于c# - 如何跳过不良记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8866512/