Erreur lecture attributs d’un « raccourci » avec Scripting.FileSystemObject
Salut
Apres de multiples essais, je ne parviens toujours pas à trouver la solution lors de l’utilisation de ce code
Code:
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
| Private Sub Form_Load()
'
Set fs = CreateObject("Scripting.FileSystemObject")
'
End Sub
Private Sub Command1_Click(Index As Integer)
'
Case 6: AfficheAttribut "C:\PersoFrancis\TousChiff", "fichier"
'
End Sub
Sub AfficheAttribut(specfichier, DossierOuFichier As String)
If LCase(DossierOuFichier) = "dossier" Then
Set f = fs.GetFolder(specfichier)
Else
' *********************** lerreur ce produit ici **********************
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 |
TousChiff est le nom d’un raccourci dans le dossier spécifié, l’erreur, à la ligne indiquée dans le code, ne survient que pour les fichiers « raccourci », erreur 53 « Fichier introuvable ».
Pour tout autres fichiers ou dossiers, pas de problème, mis a par la détection d’un fichier compressé de type .rar ou .zip qui ne renvoie pas Att >= 128 (Att fournit par f.Attributes), mais là pas d’erreur.
Merci de vous penchez, (pas trop fort tout de même ;) ) sur mon petit problème.