Создание каталога
Как создать каталог?
Цитата:
BOOL CreateDirectory(
LPCTSTR lpPathName, // pointer to a directory path string
LPSECURITY_ATTRIBUTES lpSecurityAttributes // pointer to a security descriptor
);
LPCTSTR lpPathName, // pointer to a directory path string
LPSECURITY_ATTRIBUTES lpSecurityAttributes // pointer to a security descriptor
);
Код:
CreateDirectory(TEXT("c:\\NewDirectory"), NULL);
_mkdir, _wmkdir
Create a new directory.
int _mkdir( const char *dirname );
int _wmkdir( const wchar_t *dirname );
Return Value
Each of these functions returns the value 0 if the new directory was created. On an error the function returns –1 and sets errno as follows:
EEXIST
Directory was not created because dirname is the name of an existing file, directory, or device
ENOENT
Path was not found
Parameter
dirname
Path for new directory
Remarks
The _mkdir function creates a new directory with the specified dirname. _mkdir can create only one new directory per call, so only the last component of dirname can name a new directory. _mkdir does not translate path delimiters. In Windows NT, both the backslash ( \) and the forward slash (/ ) are valid path delimiters in character strings in run-time routines.
_wmkdir is a wide-character version of _mkdir; the dirname argument to _wmkdir is a wide-character string. _wmkdir and _mkdir behave identically otherwise.
Generic-Text Routine Mappings
TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tmkdir _mkdir _mkdir _wmkdir
Example
/* MAKEDIR.C */
#include <direct.h>
#include <stdlib.h>
#include <stdio.h>
void main( void )
{
if( _mkdir( "\\testtmp" ) == 0 )
{
printf( "Directory '\\testtmp' was successfully created\n" );
system( "dir \\testtmp" );
if( _rmdir( "\\testtmp" ) == 0 )
printf( "Directory '\\testtmp' was successfully removed\n" );
else
printf( "Problem removing directory '\\testtmp'\n" );
}
else
printf( "Problem creating directory '\\testtmp'\n" );
}
Output
Directory '\testtmp' was successfully created
Volume in drive C is CDRIVE
Volume Serial Number is 0E17-1702
Directory of C:\testtmp
05/03/94 12:30p <DIR> .
05/03/94 12:30p <DIR> ..
2 File(s) 0 bytes
17,358,848 bytes free
Directory '\testtmp' was successfully removed