Bonjour
Private Sub DeleteAndKeepFiles(ByVal dir As String, ByVal keepfile As String)
Try
For Each file As String In Directory.GetFiles(dir)
Dim info As New FileInfo(file)
If info.Name <> keepfile Then
IO.File.Delete(file)
End If
Next
For Each SUBDIR As String In Directory.GetDirectories(dir)
DeleteFiles(SUBDIR, keepfile)
Next
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
'pour utiliser
Dim PATHDOSSIER As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\Microsoft\Media Player"
If System.IO.Directory.Exists(PATHDOSSIER) Then
DeleteAndKeepFiles(PATHDOSSIER,"CurrentDatabase_372.WMP")