1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
| Imports System.IO
Imports System
Imports System.Drawing
Public Class Form1
Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim chemin As String
chemin = FolderBrowserDialog1.SelectedPath
ListBox3.Items.Add(chemin)
Dim i As Integer = 0
For Each file As String In Directory.GetFiles("P:\CTRL_Projets\DTM_Repository", "*.exe", System.IO.SearchOption.AllDirectories)
Dim lStr As String = file
Dim lDossierNom As String = IO.Path.GetFileName(IO.Path.GetDirectoryName(lStr))
Dim startIndex As Integer = 30
Dim length As Integer = 20
Dim substring As String = file.Substring(startIndex, length)
Dim LaDate As Date = IO.File.GetLastWriteTime(file)
i = i + 1
ListBox2.Items.Add(LaDate)
ListBox2.Visible = False
ListBox1.Items.Add(substring)
ListBox1.Visible = False
ListBox5.Items.Add(lDossierNom)
ListBox5.Visible = False
ListBox6.Items.Add(file)
ListBox6.Visible = False
ListBox3.Visible = True
Next
Dim nosame As String
Dim k As Integer = 0
Dim m As Integer = 0
Dim j As Integer = m
Dim nomentier As String = 0
Dim value As String = ListBox1.Items.Item(j)
Dim time As Date = ListBox2.Items.Item(j)
While j < i
k=0
While k < i
ListBox7.Items.Add(j)
Dim t1 As Date = ListBox2.Items.Item(j)
Dim t2 As Date = ListBox2.Items.Item(k)
Dim s1 As String = ListBox1.Items.Item(j)
Dim s2 As String = ListBox1.Items.Item(k)
Dim n1 As String = ListBox6.Items.Item(j)
Dim n2 As String = ListBox6.Items.Item(k)
s1 = value
t1 = time
n1 = nomentier
If String.Compare(s1, s2) = 0 Then
'Compare le premier substring au deuxième
If DateTime.Compare(t1, t2) < 0 Then
value = s2
nomentier = n2
time = t2
'Si t2 est plus jeune, il remplace la valeur du premier substring par le deuxième pour le comparer à son tour'
ElseIf DateTime.Compare(t1, t2) > 0 Then
value = s1
nomentier = n1
time = t1
't1 est plus jeune, donc on garde le même substring et on implémente k pour trouver un autre fichier plus jeune '
Else
value = s1
nomentier = n1
time = t1
End If
ElseIf String.Compare(s1, s2) <> 0 Then
nosame = 0
value = s1
time = t1
nomentier = n1
End If
k = k + 1
s1 = value
t1 = time
n1 = nomentier
End While
j=j+1
CheckedListBox1.Items.Add(nomentier)
End While
End Sub
End Class |
Partager