DeleteFile2

Deletes a file.


Syntax

FileSystem.DeleteFile2(File, UIOption, RecycleOption)

FileSystem.DeleteFile2(File, UIOption, RecycleOption, UICancelOption)


Parameters


File

String, input



Name and path of the file to be deleted.


UIOption

Enumeration, input



Whether to visually track the operation's progress. Default is OnlyErrorDialogs.


RecycleOption

Enumeration, input



Specifies whether the file should be deleted permanently or placed in the Recycle Bin. Default is DeletePermanently.


UICancelOption

Enumeration, input



Specifies what should be done if the user clicks Cancel during the operation. Default is ThrowException.


Remarks


UIOption



UIOption.AllDialogs

Show progress dialog box and any error dialog boxes.


UIOption.OnlyErrorDialogs

Only show error dialog boxes and hide progress dialog boxes. Default.


UICancelOption



UICancelOption.DoNothing

Do nothing when the user clicks Cancel.


UICancelOption.ThrowException

Throw an exception when the user clicks Cancel. Default.


RecycleOption



RecycleOption.DeletePermanently

Delete the directory permanently. Default.


RecycleOption.SendToRecycleBin

Send the directory to the Recycle Bin.


Examples

This example deletes the specified file and allows the user to confirm deletion of the file:


Sub Main()

FileSystem.DeleteFile2 "C:\Users\Public\My Directory\Test.txt", UIOption.AllDialogs, RecycleOption.SendToRecycleBin, UICancelOption.ThrowException

End Sub


This example deletes the specified file, but does not confirm deletion and does not send to the Recycle Bin:


Sub Main()

FileSystem.DeleteFile2 "C:\Users\Public\My Directory\Test.txt", UIOption.OnlyErrorDialogs, RecycleOption.DeletePermanently, UICancelOption.ThrowException

End Sub