FILE 오늘날짜로 파일이름 만들기
2006.05.23 13:28
CFileException e;
CFile fileR;
TCHAR szFilePath[_MAX_PATH];
char tmpbuf[128], ampm[] = "AM";
_tzset();
/ * Display operating system-style date and time. */
_strtime( tmpbuf );
printf( \"OS time:\\t\\t\\t\\t%s\\n\", tmpbuf );
_strdate( tmpbuf );
tmpbuf[2]='_';
tmpbuf[5]='_';
tmpbuf[8]='.';
tmpbuf[9]='T';
tmpbuf[10]='X';
tmpbuf[11]='T';
tmpbuf[12]='\\0';
::GetModuleFileName(NULL, szFilePath, _MAX_PATH);
int i=strlen(szFilePath)-1;
CString strTemp=\"\\\\\";
while (szFilePath[i--] !=92 && i>0) {
if(92 ==(int)szFilePath[i]) break;
szFilePath[i]='\0';
}
strcat(szFilePath,tmpbuf);
m_strFileName = szFilePath;
if(FileExist(m_strFileName)){
if( !fileR.Open( m_strFileName, CFile::modeWrite, &e ) ){
m_strFileName =\"\";
return TRUE;
}
}else{
if( !fileR.Open( m_strFileName, CFile::modeCreate| CFile::modeWrite, &e ) ){
m_strFileName =\"\";
return TRUE;
}
}
--------------------------------------------------------------------------------------------
Write
CFile fileR;
CFileException e;
if( !fileR.Open( m_strFileName, CFile::modeWrite, &e ) ){
return;
}else{
m_strData = chData;
// if(m_strData!=\"\") UpdateData(FALSE);
fileR.SeekToEnd();
fileR.Write( m_strData, m_strData.GetLength());
fileR.Close();
}