Microsoft® Visual Basic® Scripting Edition Delete Method |
Language Reference Version 3 |
Deletes a specified file or folder.
object.Delete forceThe Delete method syntax has these parts:
Part Description object Required. Always the name of a File or Folder object. force Optional. Boolean value that is True if files or folders with the read-only attribute set are to be deleted; False (default) if they are not.
An error occurs if the specified file or folder does not exist. The Delete method does not distinguish between folders that have contents and those that do not. The specified folder is deleted regardless of whether or not it has contents.The results of the Delete method on a File or Folder are identical to operations performed using FileSystemObject.DeleteFile or FileSystemObject.DeleteFolder.
The following example illustrates use of the Delete method:
Set fso = CreateObject("Scripting.FileSystemObject") Set a = fso.CreateTextFile("c:\testfile.txt", True) a.WriteLine("This is a test.") Set a = fso.GetFile("c:\testfile.txt") a.Delete