Code : Tout sélectionner
Enumeration
#MainWindow
#ListIconGadget
#Text1
#Repertoire
#Requete
#Text2
#Extension
#Text4
#Fichier
#Recherche
#Suppression
#Actualiser
#Text3
#Police=0
EndEnumeration
Procedure.s ListFiles(directory.s , FileName.s, extension.s , directoryid.l )
If Right(directory,1)<>"\"
directory+"\"
EndIf
ExamineDirectory(directoryid,directory,"*.*")
dirid=NextDirectoryEntry()
While dirid
Select dirid
Case 1
file.s=DirectoryEntryName()
this_extension.s=LCase(GetExtensionPart(file))
this_filename.s=LCase(Left(file,Len(file)-Len(this_extension)))
If Len(this_extension)
this_filename=Left(this_filename,Len(this_filename)-1)
EndIf
If this_extension=extension Or extension="*"
If this_filename=FileName Or FileName="*"
file.s=directory+DirectoryEntryName()
AddGadgetItem(#ListIconGadget, -1, file)
EndIf
EndIf
Case 2
If DirectoryEntryName()<>"." And DirectoryEntryName()<>".."
ListFiles(directory+DirectoryEntryName()+"\",FileName,extension,directoryid+1)
UseDirectory(directoryid)
EndIf
EndSelect
dirid=NextDirectoryEntry()
Wend
ProcedureReturn ""
EndProcedure
Procedure Recherche(valeur.l)
ListFiles(GetGadgetText(#Repertoire),GetGadgetText(#Fichier),GetGadgetText(#Extension),0)
If CountGadgetItems(#ListIconGadget)=0
MessageRequester("Info", "Aucun fichier n'a été trouvé", #PB_MessageRequester_Ok)
Else
MessageRequester("Info", "Recherche terminée", #PB_MessageRequester_Ok)
EndIf
SetGadgetText(#Text3,"")
EndProcedure
If OpenWindow(#MainWindow, 0, 0, 550, 500, #PB_Window_ScreenCentered | #PB_Window_SystemMenu, "Jbernard13")
If CreateGadgetList(WindowID()) And ListIconGadget(#ListIconGadget, 20, 160, 500, 280, "Fichiers", 400, #PB_ListIcon_MultiSelect|#PB_ListIcon_CheckBoxes)
AddGadgetColumn(#ListIconGadget,1,"Etat",80)
TextGadget(#Text1, 20, 20, 500, 20,"Indiquer le répertoire")
StringGadget(#Repertoire,20, 42, 400, 20,"c:\")
ButtonGadget(#Requete, 440, 42, 80, 20, "Répertoire")
TextGadget(#Text2, 120, 84, 100, 20,"Extension")
StringGadget(#Extension,120, 106, 40, 20,"jar")
TextGadget(#Text4, 20, 84, 100, 20,"Fichier")
StringGadget(#Fichier,20, 106, 100, 20,"*")
ButtonGadget(#Recherche, 200, 106, 120, 20, "Lancer la recherche")
ButtonGadget(#Suppression, 340, 106, 180, 20, "Supprimer les fichiers sélectionnés")
ButtonGadget(#Actualiser, 160, 460, 220, 20, "Retirer de la liste les fichiers supprimés")
LoadFont(#Police, "Courrier", 40, #PB_Font_Bold)
TextGadget(#Text3, 20, 136, 300, 20, "")
SetGadgetFont(#Text3, #Police)
CloseFont(#Police)
Repeat
event=WaitWindowEvent()
Select event
Case #PB_EventGadget
Select EventGadgetID()
Case #Requete
chemin$ = PathRequester("Sélectionner un répertoire", "c:\")
SetGadgetText(#Repertoire,chemin$)
Case #Recherche
ClearGadgetItemList(#ListIconGadget)
SetGadgetText(#Text3,"Patienter pendant la recherche S.V.P")
ThreadID=CreateThread(@Recherche(), 0)
Case #Suppression
nombre.l=0:Probleme.l=0
For Element = 0 To CountGadgetItems(#ListIconGadget)-1
If GetGadgetItemState(#ListIconGadget, Element) & #PB_ListIcon_Checked
fichier$=GetGadgetItemText(#ListIconGadget, Element, 0)
Resultat = DeleteFile(fichier$)
If Resultat
SetGadgetItemText(#ListIconGadget, Element, "Effacé", 1)
nombre=nombre+1
Else
SetGadgetItemText(#ListIconGadget, Element, "Erreur", 1)
Probleme=Probleme+1
EndIf
EndIf
Next
MessageRequester("Info", "Nb de fichiers supprimés: "+Str(nombre), #PB_MessageRequester_Ok)
If Probleme
MessageRequester("Info", Str(Probleme)+"fichier(s) n'ont pu être supprimé(s)", #PB_MessageRequester_Ok)
EndIf
Case #Actualiser
For Element = 0 To CountGadgetItems(#ListIconGadget)-1
texte$=GetGadgetItemText(#ListIconGadget, Element,1)
If texte$="Effacé"
RemoveGadgetItem(#ListIconGadget, Element)
Element=Element-1
EndIf
Next
EndSelect
Case #PB_EventCloseWindow
Quit=1
EndSelect
Until Quit
EndIf
EndIf
End