2010년 7월 8일 목요일

선택한 폴더의 경로 가져오기

void CTestDlg::OnBnClickedButton1()

{

    // TODO: 여기에컨트롤알림처리기코드를추가합니다.

    ITEMIDLIST *pBrowse;

    char pathName[260];

    int count = 0;

     

   

    CString title = (CString)"폴더를선택하세요";

    BROWSEINFO brInfo;

    brInfo.hwndOwner = GetSafeHwnd();

    brInfo.pidlRoot = NULL;

   

    brInfo.pszDisplayName = (LPWSTR)pathName;

    brInfo.lpszTitle = title;

    brInfo.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;

    brInfo.lpfn = NULL;

    brInfo.lParam = 0;

    ::ZeroMemory(pathName, 260);

    pBrowse = SHBrowseForFolder(&brInfo);

    if(pBrowse != NULL)

    {

        ::SHGetPathFromIDList(pBrowse, (LPWSTR)pathName);

       

    }

   

    UpdateData(TRUE);

    m_Path.SetWindowText((LPCTSTR)pathName);

    strPath.Format((CString)"%s\\*.*", pathName);

     

   

    CFileFind find;

   

    CString fName;

   

    find.FindFile((LPCTSTR)strPath);

       

    while(find.FindNextFile())

    {

        fName = find.GetFileName();

        if(find.IsDirectory() != TRUE)

            fileList.Add(fName);

    }

}

선택한 폴더내에 있는 모든파일들을 파일리스트에 저장

0 개의 댓글:

댓글 쓰기