Sub DeleteFile(ByVal FilePath As String)
If My.Computer.FileSystem.FileExists(FilePath) = True Then
My.Computer.FileSystem.DeleteFile(FilePath)
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