two ways to automatically create folders
1, CreateDictionary ()
CreateDirectory (MyPath, 0); Create a folder for this app in the Temp folder
The prototype is: BOOL WINAPI createdirectory (__in lpctstr lppathname, __in lpsecurity_attributes lpsecurityattributes);
Where Lppathname is the path to the directory to be created, and the 2nd involves a security issue null is OK
For example:
Char "" ; GetTempPath (MAX_PATH, PATH); // Find the path of the temporary directory of the native and coexist in the character array path, MAX_PATH represents the maximum length of the character array CString MyPath = path + CString ("processassistantfile\\"); // Add the name of the new folder after the path 0 // Create a folder for this app in the Temp folder
_mkdir to create a new subdirectory
It is important to note that Windows _mkdir () requires only a path parameter, prototype: int _mkdir (const char* dirname);
EG1:
void CreateFolder (constchar* folder) { _mkdir (folder);}
EG2: In the form of a system command, that is, systems (), in the header file stdio.h
#include <iostream>#include<string>#include<cstdlib>using namespacestd;intMain () {intCounter =0; while(1) { stringStringdir ="ABCDEF"+counter; System ("mkdir"+stringdir). C_STR ());//c_str () converts the string type to char* type, GetBuffer () turns the CString type to char* typecounter++; }}
The Linux mkdir () requires two parameters, the first is the path, the second is the permission
int mkdir (const char* path,mode_t mode);
#include <sys/types.h><sys/stat.h>
... int = mkdir ("/home/cnd/mod1", S_irwxu | S_irwxg | S_iroth | S_ixoth);
You can also use system commands, that is, systems (), in the header file stdio.h
void CreateFolder (constchar* folder) { char str[] ; " mkdir%s " // folder is the name of the incoming file to be created, sprintf can connect the statement System (STR); // Create Folder }
Two ways to automatically create folders