You need to delete a file or, even better, send it to the Recycle Bin.
The My.Computer. FileSystem. DeleteFile( ) method allows you to either permanently delete a file or send it to the Recycle Bin. The basic syntax is:
My.Computer.FileSystem.DeleteFile(filePath _ [, showUI [, recycle [, onUserCancel]]] )
To send the file to the Recycle Bin, the recycle option needs to be set appropriately:
My.Computer.FileSystem.DeleteFile(filePath, _ UIOption.OnlyErrorDialogs, _ RecycleOption.SendToRecycleBin)
The first DeleteFile() argument accepts a single file to be deleted, and you can include up to three additional optional arguments: showUI (which impacts user presentation during the deletion), recycle (which indicates whether or not to use the Recycle Bin), and onUserCancel (which sets what happens when the user aborts the deletion).
The showUI argument accepts one of the following Microsoft.VisualBasic.FileIO.UIOption enumeration values:
An animated progress dialog appears during the file deletion to indicate the current status during that operation. (The dialog might not appear for deletes that involve a small amount of content.) Any errors that occur present their own separate error-dialog prompts.
While errors will appear through distinct error-dialog prompts, no animated status display appears, no matter how long the delete takes. This is the default method.
The recycle argument accepts one of the following Microsoft.VisualBasic.FileIO.RecycleOption enumeration values:
The file is immediately and permanently removed from the disk.
Instead of deleting the file, DeleteFile( ) moves the file to the Recycle Bin pseudodirectory.
If you include the onUserCancel argument, you provide it one of the following Microsoft.VisualBasic.UICancelOption enumeration values:
The on-screen status display during a delete operation includes a Cancel button. If the user clicks the Cancel button when the DoNothing option is in effect, the code calling DeleteFile( ) will not receive any notification that the deletion was aborted early.
If the user clicks the Cancel button on the status dialog when ThrowException is used, the DeleteFile( ) method generates a System.IOException exception, which can be caught by the initiating code. This is the default method.