Delete a file in VB.Net

  • Thread starter Thread starter -OSD-
  • Start date Start date
O

-OSD-

Guest
Hi,

Kind of stuck with deleting a file, file do exists but application didn't delete this file.

If System.IO.File.Exists("C:\Windows\System32\1.exe") Then
System.IO.File.Delete("C:\Windows\System32\1.exe")
End If

Then tried the following as well, but no success:

Dim FileToDelete As String
FileToDelete = "C:\Windows\System32\1.exe"
If System.IO.File.Exists(FileToDelete) = True Then
System.IO.File.Delete(FileToDelete)
MessageBox.Show("File Deleted")
End If


What I am doing wrong?

Continue reading...
 
Back
Top