'''
''' Deletes a specific file on directory/drive
'''
''' Root dirrectory to start check
''' File to delete
'''
'''
Function DeleteFile(ByVal strRootPath As String, ByVal strFileToDelete As String) As Integer
Try
Dim x As Integer = 0
Dim FullDir() As String = IO.Directory.GetDirectories(strRootPath)
For Each Dir As String In FullDir
If Dir <> (strRootPath & "System Volume Information") Then
Dim FullFiles() As String = IO.Directory.GetFiles(Dir, strFileToDelete, SearchOption.AllDirectories)
For Each File As String In FullFiles
My.Computer.FileSystem.DeleteFile(File)
x += 1
Next
End If
Next
Return x
Catch ex As Exception
Return 0
End Try
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show(DeleteFile("c:\", "abc.ini"))
End Sub
|