However my function is not detecting a newline and exiting the loop after the end of the first line.
* 'del_2' is equal to a new line character, i have tested this using a small bit of code
Expand|Select|Wrap|Line Numbers
- if del_2 = ControlChars.NewLine then
- MessageBox.Show("It is a newline")
- end if
Expand|Select|Wrap|Line Numbers
- Public Shared Function DetermineColumns(ByVal filepath As String, ByVal delimiters As KeyValuePair(Of String, String)) As List(Of KeyValuePair(Of String, Type))
- Dim result As New List(Of KeyValuePair(Of String, Type))
- Dim reader As New StreamReader(filepath)
- Dim filecontents As String = ""
- While reader.EndOfStream() = False
- filecontents = filecontents & reader.ReadLine() & ControlChars.NewLine
- End While
- reader.Close()
- reader.Dispose()
- Dim del_1 = delimiters.Key, del_2 As String = delimiters.Value
- Dim read As String = ""
- For i As Integer = 0 To (filecontents.Length - 1) Step 1
- Dim curr_char As String = filecontents(i)
- If curr_char <> del_1 And curr_char <> del_2 Then
- read = read & curr_char
- Else
- If curr_char = del_1 Then
- result.Add(New KeyValuePair(Of String, Type)(String.Format("{0}_{1}", DetermineDataType(read).Name, i.ToString()), DetermineDataType(read)))
- read = ""
- End If
- If curr_char = del_2 Then
- Exit For
- End If
- End If
- Next
- Return result
- End Function