Platform SDK: Files and I/O |
The CreateDirectory function creates a new directory. If the underlying file system supports security on files and directories, the function applies a specified security descriptor to the new directory.
To specify a template directory, use the CreateDirectoryEx function.
BOOL CreateDirectory( LPCTSTR lpPathName, // directory name LPSECURITY_ATTRIBUTES lpSecurityAttributes // SD );
There is a default string size limit for paths of 248 characters. This limit is related to how the CreateDirectory function parses paths.
Windows NT/2000: To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see File Name Conventions.
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Some file systems, such as NTFS, support compression or encryption for individual files and directories. On volumes formatted for such a file system, a new directory inherits the compression and encryption attributes of its parent directory.
Windows NT/2000: An application can obtain a handle to a directory by calling CreateFile with the FILE_FLAG_BACKUP_SEMANTICS flag set. For a code example, see CreateFile.
MAPI: For more information, see Syntax and Limitations for Win32 Functions Useful in MAPI Development.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
File I/O Overview, File I/O Functions, CreateDirectoryEx, CreateFile, RemoveDirectory, SECURITY_ATTRIBUTES