Class TextFileImporter
Public Function ImportFile() As ValidationIssuesList
'For each line in file, parse data into in-memory DataTable Using fileReader As New IO.StreamReader(m_filePath)
Try
Do While fileReader.Peek() >= 0 CurrentLineNumber += 1
'Read next line of text from file Dim strLineText As String = fileReader.ReadLine
'Importing the line into the DataTable ImportLine(strLineText)
Loop
Catch ex As Exception RecordImportIssueForCurrentLine(New _ ValidationIssue(String.Format("Error occurred" & _ " during import of file: {0}", ex.Message)))
End Try
End Using
Return m_importIssues End Function
Protected Sub ImportLine(ByVal LineText As String)
Dim row As DataRow = m_data.NewRow Try 'Parse data into a string array Dim astrValues As String() astrValues = ParseValuesFromLine(LineText)
'Put values from string array into data PutValuesInRow(row, astrValues)
'Validate data ValidateDataRow(row)
'Store valid data into table m_data.Rows.Add(row)
Catch ex As Exception RecordImportIssueForCurrentLine(New _ ValidationIssue("Error during import: " & ex.Message))
End Try
End Sub
Protected MustOverride Function ParseValuesFromLine(ByVal _ LineText As String) As String()
End Class
วันจันทร์ที่ 27 สิงหาคม พ.ศ. 2550
VB.net:ImportFile
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น