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?
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:
Private Sub btnOpen_Click(sender As System.Object, e As System.EventArgs) Handles btnOpen.Click dlgOpen.InitialDirectory = "C:\Users\USUARIO\Desktop\Word Lists\" dlgOpen.Title = "Choose which file to work on" dlgOpen.Filter = "Text Files(*.txt)|*.txt|CSV Files(*.csv)|*.csv" dlgOpen.Multiselect = True Dim LineCount As Integer = 0 Dim CheckCancel As Integer CheckCancel = dlgOpen.ShowDialog() If CheckCancel <> DialogResult.Cancel Then LblFile.Text = Path.GetFileName(dlgOpen.FileName) Dim MyFileAndPath As String = dlgOpen.FileName 'load the file TheMasterList = Nothing ' this is declared publicly at the beginning of the class. ListBox1.Items.Clear() For Each WordList As String In dlgOpen.FileNames If TheMasterList Is Nothing Then TheMasterList = TheNewList Else [COLOR="#FF0000"][B]TheMasterList.Concat(TheNewList)[/B][/COLOR] End If Next LineCount += TheMasterList.Count lblLines.Text = LineCount.ToString ListBox1.Items.AddRange(TheMasterList.ToArray) End If End Sub