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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
| Option Explicit
Dim fs As Object
Dim f, f1, sf
Dim Msg$
Dim T As Integer
Dim UniteR As String, DossieR As String, FichiieR As String
Dim CheminEtFichieR As String
Private Sub Drive1_Change()
On Error Resume Next
Dir1.Path = Drive1.Drive
If Err Then 'unité non valide(pas de CD ou de Disquette ou ....)
Err.Clear: Drive1.Drive = UniteR
TextChemComplet = CheminEtFichieR
Exit Sub
End If
UniteR = Drive1.Drive
End Sub
Private Sub Dir1_Change()
If Right(Dir1.Path, 1) <> "\" Then
DossieR = Dir1.Path & "\"
Else
DossieR = Dir1.Path
End If
If Dir1.ListIndex = -1 Then
CheminEtFichieR = DossieR
TextChemComplet = CheminEtFichieR
End If
File1.Path = DossieR
If File1.ListCount >= 1 Then
File1.ListIndex = 0
Else
FichiieR = ""
CheminEtFichieR = DossieR
TextChemComplet = CheminEtFichieR
End If
End Sub
Private Sub File1_Click()
If File1.ListCount >= 1 Then
FichiieR = File1.List(File1.ListIndex)
CheminEtFichieR = DossieR & FichiieR
Else
FichiieR = ""
CheminEtFichieR = DossieR
End If
TextChemComplet = CheminEtFichieR
End Sub
Private Sub TextChemComplet_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
Private Sub Form_Load()
'Placement des controls
Label1.Move 60, 60, 2265, 195: Label1.Caption = "ACTIF : Unité Dossier Fichier"
TextChemComplet.Move 60, 330, 7065, 285: TextChemComplet.Text = ""
Drive1.Move 30, 690, 1755
Dir1.Move 30, 1050, 3495
File1.Move 30, 2310, 3495, 2430
TextInf.Move 60, 4770, 3435, 2055: TextInf.Text = ""
TextInfos.Move 3630, 2820, 3495, 1905: TextInfos.Text = ""
TextInfos.ScrollBars = 2
Command1(0).Move 3660, 1050, 1725, 405: Command1(0).Caption = "DateCreat Fichier"
Command1(1).Move 3660, 1500, 1725, 405: Command1(0).Caption = "Nom Court"
Command1(2).Move 3660, 1950, 1725, 405: Command1(0).Caption = "Liste Dos/fich"
Command1(5).Move 3660, 2400, 1725, 405: Command1(0).Caption = "Taille fichier"
Command1(3).Move 5430, 1050, 1725, 405: Command1(0).Caption = "Infos Acces Fichier"
Command1(4).Move 5430, 1500, 1725, 405: Command1(0).Caption = "Taille Dossier"
Command1(6).Move 5430, 1950, 1725, 405: Command1(0).Caption = "Attribut fichier"
Command1(7).Move 5430, 2400, 1725, 405: Command1(0).Caption = "Attribut dossier"
UniteR = Drive1.Drive
File1.Hidden = True
If Right(Dir1.Path, 1) <> "\" Then
DossieR = Dir1.Path & "\"
Else
DossieR = Dir1.Path
End If
If File1.ListCount >= 1 Then
File1.ListIndex = 0
Else
FichiieR = ""
End If
Set fs = CreateObject("Scripting.FileSystemObject")
End Sub
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0: AfficherInfoFichier CheminEtFichieR
Case 1: AfficheNomCourt DossieR, "dossier"
Case 2: AfficheListeDossier DossieR
Case 3: AfficheInfoAccesFichier CheminEtFichieR
Case 4: AfficheTailleDossier DossieR, "dossier"
Case 5: AfficheTailleDossier CheminEtFichieR, "fichier"
Case 6: AfficheAttribut CheminEtFichieR, "fichier"
TextInf = FichiieR & vbCrLf & "Infos attribut " & GetAttr(CheminEtFichieR) & vbCrLf _
& DefiniAttrib(GetAttr(CheminEtFichieR))
Case 7: AfficheAttribut DossieR, "dossier"
TextInf = DossieR & vbCrLf & "Infos attribut " & GetAttr(DossieR) & vbCrLf _
& DefiniAttrib(GetAttr(DossieR))
End Select
End Sub
Sub AfficheInfoAccesFichier(specfichier)
If FichiieR = "" Then Beep: TextInfos.Text = "pas de fichier actif": Exit Sub
Set f = fs.GetFile(specfichier)
Msg$ = f.Name & " on Drive " & UCase(f.Drive) & vbCrLf
Msg$ = Msg$ & UCase(f.Name) & " est dans " & UCase(f.ParentFolder) & vbCrLf
Msg$ = Msg$ & "Créé le : " & f.DateCreated & vbCrLf
Msg$ = Msg$ & "Dernier accès le : " & f.DateLastAccessed & vbCrLf
Msg$ = Msg$ & "Dernière modification le : " & f.DateLastModified
TextInfos.Text = "Infos d'accès au fichier" & vbCrLf & Msg$
End Sub
Sub AfficherInfoFichier(specfichier)
If FichiieR = "" Then Beep: TextInfos.Text = "pas de fichier actif": Exit Sub
Set f = fs.GetFile(specfichier)
Msg$ = f.DateCreated
TextInfos.Text = "Date création " & vbCrLf & Msg$
End Sub
Sub AfficheNomCourt(specfichier As String, DossierOuFichier As String)
If LCase(DossierOuFichier) = "dossier" Then
Set f = fs.GetFolder(specfichier)
Else
Set f = fs.GetFile(specfichier)
End If
Msg$ = "Le nom abrégé de " & "" & UCase(f.Name) & vbCrLf
Msg$ = Msg$ & "est : " & "" & f.ShortName & ""
TextInfos.Text = "Infos de nom abrégé" & vbCrLf & Msg$
End Sub
Sub AfficheListeDossier(specdossier)
Set f = fs.GetFolder(specdossier)
Set sf = f.SubFolders
Msg$ = "": T = 0
For Each f1 In sf
Msg$ = Msg$ & f1.Name & vbCrLf
T = T + 1
Next
TextInfos.Text = T & " Dossier(s) contenu(s) dans " & specdossier & vbCrLf & Msg$
TextInfos.Text = TextInfos.Text & String$(25, "-")
Set sf = f.Files
Msg$ = "": T = 0
For Each f1 In sf
Msg$ = Msg$ & f1.Name & vbCrLf
T = T + 1
Next
TextInfos.Text = TextInfos.Text & vbCrLf & T & " Fichier(s) contenu(s) dans " & specdossier & vbCrLf & Msg$
End Sub
Sub AfficheTailleDossier(specfichier, DossierOuFichier As String)
If LCase(DossierOuFichier) = "dossier" Then
Set f = fs.GetFolder(specfichier)
Else
If FichiieR = "" Then Beep: TextInfos.Text = "pas de fichier actif": Exit Sub
Set f = fs.GetFile(specfichier)
End If
Msg$ = UCase(f.Name) & " uses " & f.Size & " bytes."
TextInfos.Text = "Infos de taille du dossier" & vbCrLf & Msg$
End Sub
Sub AfficheAttribut(specfichier, DossierOuFichier As String)
If LCase(DossierOuFichier) = "dossier" Then
Set f = fs.GetFolder(specfichier)
Else
If FichiieR = "" Then Beep: TextInfos.Text = "pas de fichier actif": Exit Sub
Set f = fs.GetFile(specfichier)
End If
Msg$ = UCase(f.Name) & " attribut: " & f.Attributes & vbCrLf
Msg$ = Msg$ & DefiniAttrib(f.Attributes)
TextInfos.Text = "Infos attribut" & vbCrLf & Msg$
End Sub
Private Function DefiniAttrib(Att As Integer) As String
DefiniAttrib = ""
'If Att >= 2048 Then DefiniAttrib = " Compressé": Att = Att - 2048
'If Att >= 1024 Then DefiniAttrib = DefiniAttrib & " Alias": Att = Att - 1024
If Att >= 128 Then DefiniAttrib = " Compressé": Att = Att - 128
If Att >= 64 Then DefiniAttrib = DefiniAttrib & " Lien ou raccourci": Att = Att - 64
If Att >= 32 Then DefiniAttrib = DefiniAttrib & " Archive": Att = Att - 32
If Att >= 16 Then DefiniAttrib = DefiniAttrib & " Dossier": Att = Att - 16
If Att >= 8 Then DefiniAttrib = DefiniAttrib & " Volume": Att = Att - 8
If Att >= 4 Then DefiniAttrib = DefiniAttrib & " System": Att = Att - 4
If Att >= 2 Then DefiniAttrib = DefiniAttrib & " Caché": Att = Att - 2
If Att = 1 Then DefiniAttrib = DefiniAttrib & " Lecture seulement"
If Att = 0 Then DefiniAttrib = DefiniAttrib & " Normal"
End Function |
Partager