Problem about opening file
-
LPCTSTR lpszPathName; CFileDialog fileDlg(TRUE); fileDlg.m_ofn.lpstrTitle="Open"; fileDlg.m_ofn.lpstrFilter="BMP Files(*.bmp)\0*.bmp\0\0"; if(fileDlg.DoModal()==IDOK) lpszPathName=fileDlg.GetPathName(); else return; CFile file; if (!file.Open(lpszPathName, CFile::modeRead | CFile::shareDenyWrite)) { AfxMessageBox("File open failed"); return; } Is there something wrong in the codes up? Thankks~
-
LPCTSTR lpszPathName; CFileDialog fileDlg(TRUE); fileDlg.m_ofn.lpstrTitle="Open"; fileDlg.m_ofn.lpstrFilter="BMP Files(*.bmp)\0*.bmp\0\0"; if(fileDlg.DoModal()==IDOK) lpszPathName=fileDlg.GetPathName(); else return; CFile file; if (!file.Open(lpszPathName, CFile::modeRead | CFile::shareDenyWrite)) { AfxMessageBox("File open failed"); return; } Is there something wrong in the codes up? Thankks~
:confused:The messagebox appears~
-
:confused:The messagebox appears~
Did you use of debugger for see value of lpszPathName is it correct and valid?
WhiteSky
-
Did you use of debugger for see value of lpszPathName is it correct and valid?
WhiteSky
I want to open a file named "aa" in path C:\Documents and Settings\示例图片\aa I saw the debugger and the content is "C:\Documents and Settings\示例图片\葺葺葺葺葺葺葺葺葺葺葺葺?" Why~?
-
I want to open a file named "aa" in path C:\Documents and Settings\示例图片\aa I saw the debugger and the content is "C:\Documents and Settings\示例图片\葺葺葺葺葺葺葺葺葺葺葺葺?" Why~?
Here is an example of opening a file open dialog box - hope this helps void CFileProc1Dlg::OnOpenBtn() { // TODO: Add your control notification handler code here this->UpdateData(); CFile f; char strFilter[] = { "Files (*.dat)|*.dat|All Files (*.*)|*.*||" }; CFileDialog FileDlg(TRUE, ".dat", NULL, 0, strFilter); if( FileDlg.DoModal() == IDOK ) { if( f.Open(FileDlg.GetFileName(), CFile::modeRead) == FALSE ) return; CArchive ar(&f, CArchive::load); ar >> m_sample; ar.Close(); } else return; f.Close(); this->UpdateData(FALSE); } -- modified at 0:58 Saturday 14th April, 2007
-
Here is an example of opening a file open dialog box - hope this helps void CFileProc1Dlg::OnOpenBtn() { // TODO: Add your control notification handler code here this->UpdateData(); CFile f; char strFilter[] = { "Files (*.dat)|*.dat|All Files (*.*)|*.*||" }; CFileDialog FileDlg(TRUE, ".dat", NULL, 0, strFilter); if( FileDlg.DoModal() == IDOK ) { if( f.Open(FileDlg.GetFileName(), CFile::modeRead) == FALSE ) return; CArchive ar(&f, CArchive::load); ar >> m_sample; ar.Close(); } else return; f.Close(); this->UpdateData(FALSE); } -- modified at 0:58 Saturday 14th April, 2007
The problem has been settled.Thanks a lot!
-
The problem has been settled.Thanks a lot!
It seems your problem solved.
WhiteSky