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
| Imports System.IO
Public Class titre2
Private Sub titre2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim utilisateur As String
utilisateur = Environ("USERNAME")
Label1.Text = utilisateur
ProgressBar2.Hide()
Label4.Hide()
Label5.Hide()
Label6.Hide()
Label7.Hide()
Label8.Hide()
Label9.Hide()
ProgressBar1.Hide()
ProgressBar2.Hide()
ProgressBar3.Hide()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim utilisateur As String
utilisateur = Environ("USERNAME")
Label1.Text = utilisateur
My.Computer.FileSystem.CreateDirectory("D:\" & utilisateur)
If MesDocuments.Checked Then
ProgressBar3.Show()
ProgressBar3.Value = 0
Label6.Show()
Label9.Show()
Timer3.Start()
My.Computer.FileSystem.CreateDirectory("D:\" & utilisateur & "\Documents")
Shell("xcopy /E C:\Users\" & utilisateur & "\Documents D:\" & utilisateur & "\Documents\")
End If
If Bureau.Checked Then
ProgressBar2.Show()
ProgressBar2.Value = 0
Label7.Show()
Label8.Show()
Timer2.Start()
My.Computer.FileSystem.CreateDirectory("D:\" & utilisateur & "\Bureau")
Shell("xcopy /E C:\Users\" & utilisateur & "\Desktop D:\" & utilisateur & "\Bureau\")
End If
If Téléchargements.Checked Then
ProgressBar1.Show()
Label4.Show()
Label5.Show()
ProgressBar1.Value = 0
Timer1.Start()
My.Computer.FileSystem.CreateDirectory("D:\" & utilisateur & "\Téléchargements")
Shell("xcopy /E C:\Users\" & utilisateur & "\Downloads D:\" & utilisateur & "\Téléchargements\")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim utilisateur As String
utilisateur = Environ("USERNAME")
Process.Start("C:\Users\" & utilisateur & "\AppData\Roaming\Thunderbird\Profiles")
End Sub
Public Shared Function FolderSize(ByVal chemin As String) As Long
Dim utilisateur As String
utilisateur = Environ("USERNAME")
Dim size As Long = 0
Dim directoryInfo As New DirectoryInfo(chemin)
Dim files As IEnumerable(Of FileInfo) = directoryInfo.GetFiles("*", SearchOption.AllDirectories) ' <--------- ICI ----------
For Each file As FileInfo In files
size += file.Length
Next
Return size
End Function
Public Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Téléchargements.Checked Then
Dim utilisateur As String
utilisateur = Environ("USERNAME")
Dim taillesourc As Double
Dim tailledest As Double
taillesourc = 0
taillesourc = FolderSize("C:\Users\" & utilisateur & "\Downloads")
tailledest = FolderSize("D:\" & utilisateur & "\Téléchargements")
ProgressBar1.Maximum = 100
ProgressBar1.Value = (tailledest / taillesourc) * 100
Label4.Text = ProgressBar1.Value & "%"
If ProgressBar1.Value > 99 Then
Timer1.Stop()
End If
End If
End Sub
Public Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If Bureau.Checked Then
Dim utilisateur As String
utilisateur = Environ("USERNAME")
Dim taillesourc As Double
Dim tailledest As Double
taillesourc = 0
taillesourc = FolderSize("C:\Users\" & utilisateur & "\Desktop")
tailledest = FolderSize("D:\" & utilisateur & "\Bureau")
ProgressBar2.Maximum = 100
ProgressBar2.Value = (tailledest / taillesourc) * 100
Label8.Text = ProgressBar2.Value & "%"
If ProgressBar2.Value > 99 Then
Timer2.Stop()
End If
End If
End Sub
Public Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
If MesDocuments.Checked Then
Dim utilisateur As String
utilisateur = Environ("USERNAME")
Dim taillesourc As Double
Dim tailledest As Double
taillesourc = 0
taillesourc = FolderSize("C:\Users\" & utilisateur & "\Documents") ' <--------- ICI ----------
Next
ProgressBar3.Maximum = 100
ProgressBar3.Value = (tailledest / taillesourc) * 100
Label4.Text = ProgressBar3.Value & "%"
If ProgressBar3.Value > 99 Then
Timer3.Stop()
End If
End Sub
End Class |
Partager