bonjour,
je voudrais de l'aide pour afficher label4.text la taille du fichier par ex:OctetsKoMoGo
voici mes codes:
je voudrais quand j'ouvre un fichier , il me dit automatique s'il est en Octets ou Ko ou Mo ou Go.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Imports System.IO Imports System.Math Public Class Form1 Dim OctetsToKoMoGo As String Dim taille As String Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim Addition As Integer = 0 Dim OpenFileDialog1 As New OpenFileDialog() OpenFileDialog1.Filter = "All Files (*.*)|*.*" If DialogResult.OK = OpenFileDialog1.ShowDialog Then TextBox1.Text = OpenFileDialog1.FileName Label2.Text = Path.GetFileName(OpenFileDialog1.FileName) Label4.Text = OpenFileDialog1.FileName.Length * OctetsToKoMoGo PictureBox1.Image = Icon.ExtractAssociatedIcon(TextBox1.Text).ToBitmap End If End Sub Sub KoMoGo() If taille < 1024 Then OctetsToKoMoGo = taille & " Octets" ElseIf taille >= 1024 And taille < 1048576 Then OctetsToKoMoGo = Round((taille / 1024), 2) & " Ko" ElseIf taille >= 1048576 And taille < 1073741824 Then OctetsToKoMoGo = Round((taille / 1048576), 2) & " Mo" ElseIf taille >= 1073741824 And taille < 1099511627776 Then OctetsToKoMoGo = Round((taille / 1073741824), 2) & " Go" End If End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click End End Sub End Class
voici en image mon projet:
merci, cordialement
Partager