Directory.Delete Method


Directory.Delete Method

Class

System.IO.Directory

Syntax

     Directory.Delete(path[, recursive]) 


path (required; String)

The path of the directory to delete.


recursive (optional; Boolean)

Indicates whether the directory and its entire contents (including nested subdirectories) are to be deleted if the directory is not empty. Its default value is False.

Description

The Delete method deletes an existing directory, with all of its contents if requested.

Usage at a Glance

  • If path does not exist, a runtime error occurs.

  • If recursive is set to False and the directory is not empty, a runtime error occurs.

  • path can be either an absolute path or a relative path from the current directory.

  • path can be either a path on the local system, the path of a mapped network drive, or a UNC path.

  • path cannot contain wildcard characters.

  • The Delete method permanently deletes directories and their contents. It doesn't move them to the Recycle Bin.

  • Care must be taken when setting recursive to TRue, especially since no prompting is done before the deletion occurs.

Version Differences

Visual Basic 2005 includes a My.Computer.FileSystem.DeleteDirectory method that provides similar functionality.




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net