Class 标记为 Deliminted 但错误提示不是
Class marked for Deliminted but error says not
我有一项可疑的任务是升级使用文件助手的旧 vb 应用程序,但出于某种原因,它似乎忽略了我已将其标记为分隔记录的事实。
在表单中,它使用以下内容将 csv 文件附加到记录,这与 c# 的做法类似。
Private Sub browseButton_Click(sender As System.Object, e As System.EventArgs) _
Handles browseButton.Click
Try
Dim file = GetFile()
'' Errors
Dim errors As New Dictionary(Of Integer, String)
If IO.File.Exists(file) Then
Dim engine As New FileHelperEngine(Of AveryOrderCsv)
_records = CType(engine.ReadFile(file), AveryOrderCsv()).ToList()
Dim count As Integer = 0
Dim success As Integer = 0
For Each averyOrderCsv As AveryOrderCsv In _records
Try
ImportProgressBar.Value = count
ImportProgressLabel.Text = String.Format("Importing {0} of {1} dockets",
count + 1, _records.Count())
System.Windows.Forms.Application.DoEvents()
If CreateSop(averyOrderCsv) Then
success = success + 1
End If
Catch ex As Exception
errors.Add(count, ex.Message)
End Try
count = count + 1
Next
End If
Catch ex As Exception
ExceptionManager.HandleUnexpectedException(ex)
End Try
Class
Imports AveryIntegration.Common.CSV
Imports FileHelpers
Imports System
Imports System.Diagnostics
Namespace AveryIntegration.Common.CSV.Records
<DelimitedRecord(",")>
Public Class AveryOrderCsv
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String2 As String
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String3 As String
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String4 As String
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String5 As String
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String10 As String
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String15 As String
Public Decimal1 As Decimal
Public Decimal5 As Decimal
Public Decimal8 As Decimal
Public Decimal9 As Decimal
Public Decimal10 As Decimal
Public Date1 As DateTime
Public Ticket2 As Integer
<DebuggerNonUserCode>
Public Sub New()
MyBase.New()
End Sub
End Class
End Namespace
我得到的错误如下,但正如您从上面看到的,我已将其声明为分隔记录并导入了 imports FileHelpers
在 VB 中,属性必须在同一逻辑行上。
<DelimitedRecord(",")> Public Class AveryOrderCsv
或
<DelimitedRecord(",")> _
Public Class AveryOrderCsv
属性相同。
In Visual Basic, the attribute is surrounded by angle brackets and must be on the same logical line; the line continuation character can be used if a line break is desired.
我有一项可疑的任务是升级使用文件助手的旧 vb 应用程序,但出于某种原因,它似乎忽略了我已将其标记为分隔记录的事实。
在表单中,它使用以下内容将 csv 文件附加到记录,这与 c# 的做法类似。
Private Sub browseButton_Click(sender As System.Object, e As System.EventArgs) _
Handles browseButton.Click
Try
Dim file = GetFile()
'' Errors
Dim errors As New Dictionary(Of Integer, String)
If IO.File.Exists(file) Then
Dim engine As New FileHelperEngine(Of AveryOrderCsv)
_records = CType(engine.ReadFile(file), AveryOrderCsv()).ToList()
Dim count As Integer = 0
Dim success As Integer = 0
For Each averyOrderCsv As AveryOrderCsv In _records
Try
ImportProgressBar.Value = count
ImportProgressLabel.Text = String.Format("Importing {0} of {1} dockets",
count + 1, _records.Count())
System.Windows.Forms.Application.DoEvents()
If CreateSop(averyOrderCsv) Then
success = success + 1
End If
Catch ex As Exception
errors.Add(count, ex.Message)
End Try
count = count + 1
Next
End If
Catch ex As Exception
ExceptionManager.HandleUnexpectedException(ex)
End Try
Class
Imports AveryIntegration.Common.CSV
Imports FileHelpers
Imports System
Imports System.Diagnostics
Namespace AveryIntegration.Common.CSV.Records
<DelimitedRecord(",")>
Public Class AveryOrderCsv
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String2 As String
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String3 As String
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String4 As String
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String5 As String
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String10 As String
<FieldConverter(GetType(CustomStringConvertor))>
<FieldQuoted>
Public String15 As String
Public Decimal1 As Decimal
Public Decimal5 As Decimal
Public Decimal8 As Decimal
Public Decimal9 As Decimal
Public Decimal10 As Decimal
Public Date1 As DateTime
Public Ticket2 As Integer
<DebuggerNonUserCode>
Public Sub New()
MyBase.New()
End Sub
End Class
End Namespace
我得到的错误如下,但正如您从上面看到的,我已将其声明为分隔记录并导入了 imports FileHelpers
在 VB 中,属性必须在同一逻辑行上。
<DelimitedRecord(",")> Public Class AveryOrderCsv
或
<DelimitedRecord(",")> _
Public Class AveryOrderCsv
属性相同。
In Visual Basic, the attribute is surrounded by angle brackets and must be on the same logical line; the line continuation character can be used if a line break is desired.