개발자 승학

mfc c++ txt 파일 읽기 본문

it/C++

mfc c++ txt 파일 읽기

유승학 2019. 3. 21. 14:19

CString m_strPath, str;

CStdioFile rFile;

CFileException ex;

CFileDialog dlg(TRUE, _T("*.txt"), NULL, OFN_FILEMUSTEXIST | OFN_OVERWRITEPROMPT, _T("TXT Files(*.txt)|*.txt|"), NULL);

if (dlg.DoModal() == IDOK)

{

m_strPath = dlg.GetPathName();

rFile.Open(m_strPath, CFile::modeReadWrite | CFile::typeText, &ex);


while (rFile.ReadString(str))

{

getFileString += (str + _T("\r\n"));

}

rFile.Close();

                // edit control에 txt파일 쓰기

mFileView.SetWindowTextW(getFileString);

}

'it > C++' 카테고리의 다른 글

c++ 스레드 사용법  (0) 2019.03.14
C++ 함수 중복  (0) 2018.06.14
Comments