et que ma listof contient :
A
B
C
D
B
C
A
D
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub AjoutSites() File.AppendAllLines(HostFilename, ListeDeSiteContenusDangereux) End Sub
Private Sub EnleveSites() Dim lines As List(Of String) = New List(Of String) For Each line In File.ReadLines(HostFilename).ToList() If Not line.EndsWith("# site dangereux") Then lines.Add(line) End If Next System.IO.File.WriteAllLines(HostFilename, lines) End Sub
IO.File.Delete(file)
Private Sub AjoutSites() Using sw As StreamWriter = New StreamWriter(HostFilename, True) For Each line In ListeDeSiteContenusDangereux sw.WriteLine(line & " # site dangereux") Next End Using End Sub Private Sub EnleveSites() Dim lines As List(Of String) = New List(Of String) Using sr As StreamReader = New StreamReader(HostFilename) Dim line As String = sr.ReadLine() While (Not line Is Nothing) If Not line.EndsWith("# site dangereux") Then lines.Add(line) End If line = sr.ReadLine() End While End Using File.WriteAllLines(HostFilename, lines) End Sub