J'espere que je suis claire
(PS : je m'excuse pour ceux qui son mordu de francais.. c'est plein de faute je le sais )
listbox2 content du MD5#
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate list1 As New List(Of String) Private list2 As New List(Of String) Private Function ReadFile(ByVal pathfichier As String) As List(Of String) Dim listitems As New List(Of String) Try listitems = System.IO.File.ReadAllLines(pathfichier).ToList Catch ex As Exception 'en cas d'exception affiche l'erreur MessageBox.Show(ex.Message) Close() End Try Return listitems End Function Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load list1 = ReadFile(Application.StartupPath & "\test1.txt") list2 = ReadFile(Application.StartupPath & "\test2.txt") ListBox1.Items.AddRange(list1.ToArray) ListBox2.Items.AddRange(list2.ToArray) If CheckContains(list1, list2) Then MessageBox.Show("list1 contains list2") Else MessageBox.Show("list1 doesn't contain list2") End If End Sub Private Function CheckContains(ByVal lista As List(Of String), ByVal listb As List(Of String)) As Boolean 'verifie si lista contient listb If listb.Count > lista.Count Then Return False End If For Each item In listb If Not lista.Contains(item) Then Return False End If Next Return True End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim abc As String Dim pqr As String() 'Load la liste email abc = My.Computer.FileSystem.ReadAllText("C:\uSyncMD5#.txt") pqr = abc.Split(vbNewLine) ListBox3.Items.AddRange(pqr) End Sub 'declaration of variables. Dim FileNumber As Integer = FreeFile() Dim file_path As String 'Our string will be the selected path of the user file_path = TextBox1.Text If Directory.Exists(file_path) Then 'Search for Mp3 in a specific path Dim mp3 As String() = Directory.GetFiles(file_path, "*.mp3") For Each file_name As String In mp3 ListBox1.Items.Add(file_name) ListBox4.Items.Add(file_name) Next file_name '"" for wav Dim wav As String() = Directory.GetFiles(file_path, "*.wav") For Each file_name As String In wav ListBox1.Items.Add(file_name) ListBox4.Items.Add(file_name) Next file_name '"" for ogg Dim ogg As String() = Directory.GetFiles(file_path, "*.ogg") For Each file_name As String In ogg ListBox1.Items.Add(file_name) ListBox4.Items.Add(file_name) Next file_name End If Do Until ListBox1.Items.Count = "0" 'Now for the Md5# part. Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider Dim f As FileStream = New FileStream(ListBox1.Items(0), FileMode.Open, FileAccess.Read, FileShare.Read, 8192) f = New FileStream(ListBox1.Items(0), FileMode.Open, FileAccess.Read, FileShare.Read, 8192) md5.ComputeHash(f) Dim hash As Byte() = md5.Hash Dim buff As StringBuilder = New StringBuilder Dim hashByte As Byte For Each hashByte In hash buff.Append(String.Format("{0:X2}", hashByte)) Next ListBox2.Items.Add(buff.ToString()) ListBox1.Items.RemoveAt(0) Loop 'Here we need to check if the current items exist 'Dont c'est ici qu'il faudrais que mon programme vérifie si chaque ligne de la listbox2 est deja présente dans la listbox3 'Then once we have checked that no items match an other we'll upload them 'We finaly update the .txt with new MD5# items. FileOpen(FileNumber, "C:\uSyncMD5#.txt", OpenMode.Output) For Each Item As Object In ListBox2.Items PrintLine(FileNumber, Item.ToString) Next FileClose(FileNumber)
Listbox1 deverais contenir tout ce qui est dans la listbox2 mais qui n'est pas présent dans la 3
Private Sub Compare() ListBox1.Items.Clear() For Each item In ListBox2.Items If Not ListBox3.Items.Contains(item) Then ListBox1.Items.Add(item) End If Next End Sub