CitectVBA Programming Reference > CitectVBA Function Reference > File I/O Functions > MkDir

MkDir

The MkDir statement creates the directory specified in the Path parameter.

The required parameter Path must be a string or expression that can represent a valid DOS file structure path value, must contain a directory name, may contain a relative path structure, and may contain a drive letter. The Path parameter must be limited to less than 128 characters.

The MkDir statement is relative to the current directory. If no path structure is provided, the directory is created in the current directory. If no drive is specified, the MkDir statement creates the directory on the current drive.

Note: The file system keeps track of the current drive, and the current directory of every drive. Use the CurDir statement to determine the current directory. The current drive letter can be extracted from the Left character returned in the CurDir statement.

Syntax

MkDirPath

Path:

A string or expression that can represent a valid DOS file structure path value. This includes a directory name, and may include a relative or static directory or folder structure and drive letter, in the order:

[<driveletter>:][\<rootdirectoryname>][\<subdirectory> ... 
\<subdirectory>\] directoryname

The path can be relative to the current directory. A single period represents the current directory (.). Two periods represent the parent directory of the current directory (..). For example:

chdir ..		' changes to the parent directory of the current directory
chdir ..\test ' changes to the test subdirectory of the parent directory

Related Functions

ChDir | ChDrive | CurDir, CurDir$ | Dir | RmDir

Example

Dim strPath As String
Dim strDir As String
strPath = CurDir() ' store current path
strDir = "Temp"
ChDir "\" ' change to root dir on current drive
MkDir strDir ' create new directory
ChDir strPath ' change back to previous path