Sub DeleteFile(ByVal FilePath As String)
If Dir(FilePath, vbHidden) <> "" Then
Dim FSO = CreateObject("Scripting.FileSystemObject")
FSO.deletefile(FilePath)
FSO = Nothing
Else
MsgBox("Le fichier à supprimer n'existe pas")
End If
End Sub
'Exemple d'utilisation
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
DeleteFile("C:\test.txt")
End Sub