CFileDialog 를 이용하여 파일의 확장자를 제외한 파일명만 가져오는 방법.
다양한 방법으로 수정 가능.
- CString str = _T("All Files(*.*)|*.*|"); // 선택할 파일 종류
- CString File, filem, strre;
- CString strFileList;
- CFileDialog dlg(TRUE, NULL, NULL, OFN_ALLOWMULTISELECT, str, this);
- const int c_cMaxFiles = 20000 /*선택할 파일 숫자*/ ;// 메모리 부족현상으로 확장 안해주면 몇개 못씀
- const int c_cbBuffSize = (c_cMaxFiles * (MAX_PATH + 1)) + 1;
- dlg.GetOFN().lpstrFile = strFileList.GetBuffer(c_cbBuffSize);
- dlg.GetOFN().nMaxFile = c_cbBuffSize;
- if( dlg.DoModal() == IDOK)
- {
- for(POSITION pos=dlg.GetStartPosition(); pos != NULL;)
- {
- // 전체삭제는 ResetContent
- File = dlg.GetNextPathName(pos);
- filem = File.Right( File.GetLength()-File.ReverseFind( _T('\\') )-1 );
- // 경로를 제외한 파일명
- filem = filem.Left( filem.GetLength() - 4 );
- // 확장자 제거 ( ex - .jpg )
- m_ListBox.AddString( filem );
- }
- }
- m_nFileCnt = m_ListBox.GetCount();
- strre.Format( _T("%dea load"), m_nFileCnt );
- AfxMessageBox( strre );
'Programming > C, C++, MFC' 카테고리의 다른 글
프로그램 실행시간을 측정 해 보자! (0) | 2014.02.12 |
---|---|
[Function][MFC] CFileFind 를 이용하여 폴더내 모든파일 리스트박스에 추가하기 (18) | 2014.01.23 |
[Function][MFC] 폴더 경로 구하기 ( CString에 선택된 폴더의 절대경로를 저장하자 ) (0) | 2014.01.23 |
프로그램 구동 속도 를 줄이는 방법! (0) | 2013.11.20 |
LPCSTR / LPCTSTR / const char* / CString 등등 문자열 형 (0) | 2013.11.11 |