'mkdirs'에 해당되는 글 1건

  1. 2015.02.09 디렉토리 생성(하위디렉토리 생성)

mfc 를 하다보면 하위디렉토리 없어서 죽는 경우가 많다.


중요한건 죽어도 제어하기 힘들다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
void mkdirs(const CString directory)
{
    CString tmpDirectory = directory;
 
    // 변수로 받은것은 무조건 폴더로 가정하여 해당 경로에 붙여준다.  
    tmpDirectory.Replace(_T('/'), _T('\\'));
     
    if (directory.Right(1).Compare(_T("\\"))) {
        tmpDirectory += (CString)_T('\\');
    }
 
    CString preDirectory;
    int nStart = 0;
    int nEnd;
 
    // 경로를 반복하여 반복 수행
    while ((nEnd = tmpDirectory.Find('\\', nStart)) >= 0)
    {
        CString csToken = directory.Mid(nStart, nEnd - nStart);
        CreateDirectory(preDirectory + csToken, NULL);
        preDirectory += csToken;
        preDirectory += _T('\\');
        nStart = nEnd + 1;
    }
}
 

위 방법 또는 아니면 

구분자(\)를 확인 후 mkdir 생성 후, chdir 를 반복해서 사용하면 만들수 있다.


'Program > MFC' 카테고리의 다른 글

Dialog 프로그램 시, Argument 받는 방법  (0) 2014.12.02
폴더 유/무 확인하도록 하는것  (0) 2014.12.01
mfc split 사용하기  (0) 2014.10.23
Posted by PARK37
,