Visual Basic 2005 Cookbook: Solutions for VB 2005 Programmers (Cookbooks (OReilly))
Problem
You need to delete a file or, even better, send it to the Recycle Bin. Solution
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) Discussion
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:
The recycle argument accepts one of the following Microsoft.VisualBasic.FileIO.RecycleOption enumeration values:
If you include the onUserCancel argument, you provide it one of the following Microsoft.VisualBasic.UICancelOption enumeration values:
|
Категории