分类:
2008-09-17 11:11:54
()
- ()
-- ()
帮帮忙看看这段代码为什么不能读取文件内容并显示出来
void CVWFILEDlg::OnCloseupDatetimepicker1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CDateTimeCtrl* pFileTime = (CDateTimeCtrl*)GetDlgItem(IDC_DATETIMEPICKER1);
CTime itemTime;
pFileTime->GetTime(itemTime);
CString FileName = itemTime.Format("%Y-%m-%d");
char* pFileName = FileName.GetBuffer(FileName.GetLength() + 1);
CStatic* pStatic;
pStatic = (CStatic*)GetDlgItem(IDC_STATIC);
CFile f;
CFileException e;
if( !f.Open( pFileName, CFile::modeRead, &e ) )
{
#ifdef _DEBUG
afxDump << "File could not be opened " << e.m_cause << "\n";
#endif
}
int flength = f.GetLength();
char* filecontent = new char[flength];
f.SeekToBegin();
f.Read(filecontent,flength);
pStatic->SetWindowText(filecontent);
f.Close();
*pResult = 0;
}
妈的,原来我忘了考虑文件的后缀名
FileName+= ".txt"; 就可以啦
全部时间均为北京时间. 现在时间是14:39 . |
Powered by: vBulletin Version 2.2.8
Translated and hacked by:
Copyright © Jelsoft Enterprises Limited 2000, 2001.