본문 바로가기
프로그래밍 _공부자료./C++ 공부

mfc 로그 폴더 생성 및 로그 txt 파일 만들기

by 대구부자 2022. 5. 12.
반응형
void CMFCApplication1Dlg::OnBnClickedOk()
{
	// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
	CString strFilePath;
	strFilePath = "../LogLogLogLog22222/";
	if (GetFileAttributes((LPCTSTR)strFilePath) ==-1)
	{
		// 디렉토리가 없으면 생성
		CreateDirectory(strFilePath, NULL);
	}
	string line;

	std::string str = std::string(CT2CA(strFilePath));
	str += "adge.txt";

	ofstream file(str);
		if (file.is_open()) {
			file << "this is second " << endl;
		}
	

	CDialogEx::OnOK();
}
반응형

댓글