Private Sub remove_duplicite(sender As Object, e As EventArgs) Dim sFiles() As String sFiles = Directory.GetFiles(filesPath1, remove_dupl) Dim path As String = String.Join("", sFiles) 'MessageBox.Show(path) Dim lines As New HashSet(Of String) 'Read to file Dim i = +1 Using sr As StreamReader = New StreamReader(path) Do While sr.Peek() >= 0 lines.Add(sr.ReadLine()) Dim sLine = sr.ReadLine If lines.Contains(sLine) Then pocet_duplicit = i + 1 'lines.Add(i & "," & sLine) Else lines.Add(sLine) End If Loop End Using Using sw As StreamWriter = New StreamWriter(path) For Each line As String In lines sw.WriteLine(line) Next logfile(sender, e) End Using Close() End Sub