Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))

Directory.CreateDirectory Method

Class

System.IO.Directory

Syntax

Directory.CreateDirectory(path)

path (required; String)

The path of the new directory

Description

The CreateDirectory method creates a new directory based on a supplied path.

Usage at a Glance

  • path can be an absolute or a relative path. For example:

    ' ----- Absolute path. Directory.CreateDirectory("C:\Temp") ' ----- Relative path. Directory.CreateDirectory("..\Chapter2")

  • If needed, CreateDirectory creates all directories down the line to the final directory. For example, the code:

    Directory.CreateDirectory("c:\NewDirectory\NewSubDirectory")

    creates the NewDirectory directory if it does not exist and then creates the NewSubDirectory directory if it does not exist.

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

  • The CreateDirectory method does not raise an error if the directory to be created already exists.

Version Differences

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

Категории