MKDIR()
Jump to navigation
Jump to search
Description
- This function attempts to create the directory specified in dirName. If successful, the function returns 0; otherwise, a system error code is returned.
- See MSDN for a list of System Error Codes (0-499)
- See also RMDIR() to remove a directory.
Syntax
- retValue = mkdir("dirName")
Hints
- To confirm that the directory was successfully created, use this test to check the value returned by the function:
result = mkdir("dirName")
if result <> 0 then notice "Directory not created."
end
- If the directory already exists, MKDIR() will return non-zero.
- You can check the returned error code, where 183 means "ERROR_ALREADY_EXISTS".
- If you need to create nested directories, like "dir1\dir2", you should first create the upper level directory ("dir1"), then the lower level ("dir1\dir2")
- Attempting to create "dir1\dir2" without existing "dir1" will fail with error code 3, "ERROR_PATH_NOT_FOUND".
Example
' To add a folder named "temp" in the current directory
' and confirm that the folder was created:
result = mkdir("temp")
' Check if folder already exists
if result = 183 then print "Folder already exists."
' Test if successful
if result <> 0 then
print "Folder was not created."
else
print "Folder has been created in ";DefaultDir$
end if
end
Useful Procedures
' Place a useful function or sub using this keyword here