¤ Hi,
¤
¤ what's the best way to import a flat file to a .NET 3.5 App?
¤
¤ Thanks for any thought
Assuming some kind of column delimiter, one method would be to use the TextFieldParser:
Dim TextFileReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\Documents and
Settings\nfisppc\My Documents\My Database\Text\Orders.txt")
TextFileReader.TextFieldType = FileIO.FieldType.Delimited
TextFileReader.SetDelimiters(",")
Dim CurrentRow As String()
While Not TextFileReader.EndOfData
Try
CurrentRow = TextFileReader.ReadFields()
Dim CurrentField As String
For Each CurrentField In CurrentRow
Console.Write(CurrentField & Space(1))
Next
Catch ex As _
Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message & _
"is not valid and will be skipped.")
End Try
Console.WriteLine()
End While
Paul
~~~~
Microsoft MVP (Visual Basic)