Directory Class


Directory Class

Namespace

System.IO

Creatable

No

Description

The Directory class has a number of members that allow you to retrieve information about directories, to move and delete a directory, and to create a new directory. All of the members of the Directory class are shared methods, so they can be called without instantiating any objects. For example, use the following statement to call the CreateDirectory method:

     Directory.CreateDirectory("C:\projects\project1") 

The following table lists some of the more useful and interesting members of the Directory class. Those marked with an asterisk (*) have separate entries in this chapter.

Member

Description

CreateDirectory Method *

Creates a new directory

Delete Method *

Deletes an existing directory

Exists Method *

Tests a directory to see if it exists

GetCreationTime Method *

Gets the original creation date and time of a directory

GetCurrentDirectory Method

Gets the directory used for the "current" directory, from which all relative paths derive

GetDirectories Method *

Gets an array of all directories within a parent directory

GetDirectoryRoot Method *

Gets the drive root of a given directory

GetFiles Method *

Gets an array of all files within a parent directory

GetFileSystemEntries Method *

Gets an array of all files and directories within a parent directory

GetLastAccessTime Method

Gets the date and time that a directory was last accessed

GetLastWriteTime Method

Gets the date and time that a directory was last modified

GetLogicalDrives Method *

Gets an array of all logical drives on the local system

GetParent Method *

Gets the parent directory of a given directory

Move Method *

Moves a directory to a new location

SetCurrentDirectory Method

Selects the directory used for the "current" directory, from which all relative paths derive


Version Differences

  • The Directory object loosely corresponds to the Folder object in the FileSystem Object object model, part of the Microsoft Scripting Runtime Library and often used in VBScript and ASP-based web development. There is, however, a significant difference in the members of each class, and, in some cases, methods with similar functionality have different names.

  • Visual Basic 2005 includes a My.Computer.FileSystem object that provides directory management functionality.

See Also

File Class




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