Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42215

VS 2010 [RESOLVED] List(of T).Concat not working

$
0
0
My code is below. What should happen is that I select several files in the OpenDialog and it adds them all together as a master list.
What actually happens is that it only recognises the first file. It does not throw an error, it just does not add any more lines from the second, third etc files.
Any ideas why please?
vb.net Code:
  1. Private Sub btnOpen_Click(sender As System.Object, e As System.EventArgs) Handles btnOpen.Click
  2.         dlgOpen.InitialDirectory = "C:\Users\USUARIO\Desktop\Word Lists\"
  3.         dlgOpen.Title = "Choose which file to work on"
  4.         dlgOpen.Filter = "Text Files(*.txt)|*.txt|CSV Files(*.csv)|*.csv"
  5.         dlgOpen.Multiselect = True
  6.         Dim LineCount As Integer = 0
  7.         Dim CheckCancel As Integer
  8.         CheckCancel = dlgOpen.ShowDialog()
  9.         If CheckCancel <> DialogResult.Cancel Then
  10.             LblFile.Text = Path.GetFileName(dlgOpen.FileName)
  11.             Dim MyFileAndPath As String = dlgOpen.FileName
  12.             'load the file
  13.             TheMasterList = Nothing ' this is declared publicly at the beginning of the class.
  14.             ListBox1.Items.Clear()
  15.             For Each WordList As String In dlgOpen.FileNames
  16.                 Dim TheNewList As List(Of String) = (File.ReadAllLines(MyFileAndPath).ToList())
  17.                 If TheMasterList Is Nothing Then
  18.                     TheMasterList = TheNewList
  19.                 Else
  20.                     [COLOR="#FF0000"][B]TheMasterList.Concat(TheNewList)[/B][/COLOR]
  21.                 End If
  22.             Next
  23.             LineCount += TheMasterList.Count
  24.             lblLines.Text = LineCount.ToString
  25.             ListBox1.Items.AddRange(TheMasterList.ToArray)
  26.         End If
  27.     End Sub

Viewing all articles
Browse latest Browse all 42215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>