Navigation: Advanced Topics > Clarion Language Utilities >====== CreateDirectory (Create a directory) ====== | |
CREATEDIRECTORY( directoryname )
CREATEDIRECTORY | Create a new directory |
directoryname | A string constant or variable that stores the directory name |
CREATEDIRECTORY creates a new directory with the name passed in the directoryname parameter. CREATEDIRECTORY returns zero (0) if successful, and non-zero if not. You can query the ERRNO built-in function to trap for the following error codes:
3 ' Path not found (One of the higher path components in directoryname)
5 ' Access Denied (Possible Security Rights)
183 ' Directory Already Exisits
On some Windows versions, any attempt to create multiple levels of directories
(For example. 'C:\dir1\dir2\dir3') will fail, but the error code will not be returned correctly. CREATEDIRECTORY will still post a non-zero value, which you can use to trap and post a generic “Directory Not Created” error.
To add this function to your existing applications, you need only include the CWUTIL.INC file in the Global Map section of your program:
INCLUDE('CWUTIL.INC'),ONCE
Return Data Type: BYTE
Example:
PROGRAM
GLO:NewDirectoryName STRING(200)
MAP
INCLUDE('CWUTIL.INC'),ONCE
MODULE('')
errno(),*SIGNED,NAME('errno') !prototype built-in error flag
END
END
!Make sure project define has _ABCLinkMode_⇒1
CODE
GLO:NewDirectoryName = CLIP('C:\Temp')
IF CreateDirectory(GLO:NewDirectoryName)
CASE Errno()
OF 3
MESSAGE('Path Not Found')
OF 5
MESSAGE('Access Denied')
OF 183
MESSAGE('Directory Already Exists')
END
END
See Also: