创建文件夹目录的相关方法:
(1).采用CreateDirectory函数
CString strPath;
GetModuleFileName(NULL,strPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH);
strPath.ReleaseBuffer();
int pos = strPath.ReverseFind('\\');
strPath = strPath.Left(pos);
CString strLogPath;
strLogPath = strPath + L"\\Log";
if (!PathIsDirectory(strLogPath))
{
CreateDirectory(strLogPath,0);
}
(2).采用
C运行库函数int mkdir()和int _mkdir()
//声明标识符
USES_CONVERSION;
//调用函数,T2A和W2A均支持ATL和MFC中的字符转换
char * pLogPath = T2A(strLogPath);
_mkdir(pLogPath);
(3).
调用system命令md
char chLogPath[MAX_PATH]="";
sprintf_s(chLogPath,sizeof(chLogPath),"md %s",pLogPath);
system(chLogPath);
删除文件夹目录的相关方法。
依据上述创建方法,同样有对应的三种删除方法。
(1).调用调用Windows API函数 RemoveDirectory()
(2).调用C运行库函数int rmdir()和int _rmdir()(3).调用system命令rd