Ive been trying to use the Open and Save FileDlg in MFC and then use that GetFileName to allow me to read a log file and then update a list control i have in a dialog form. Now when i run the small dialog app and click the open dialog button. It allows me to browse to the file and select it and when i press ok it comes up with "an unamed file was not found" Ive been looking at lots of CFile::Read examples but i just cant seem to see what im doing wrong here. Any ideas?
Code:void CReaderDlg::OnBnClickedButton1() { char strFilter[] = { "Log Files (*.log)|*.log|All Files (*.*)|*.*||" }; CFileDialog FileDlg(TRUE,".log",NULL,0,strFilter); if(FileDlg.DoModal()==IDOK) { CFile file; DWORD filesize; char buffer[2000]; filesize = file.GetLength(); file.Open(FileDlg.GetFileName(),CFile::modeReadWrite); file.Read(buffer,filesize); m_ListChat.InsertItem(0,buffer); file.Close(); } else { return; } }




Reply With Quote