文件打开操作: CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"ALL Files (*.*)|*.*||",this); if(dlg.DoModal()==IDOK) dlg.GetFileName(); else return; //add own process 文件保存操作: CFileDialog dlg(FALSE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"JPEG (*.jpg)|*.*||",AfxGetMainWnd()); CString strPath,strName; if(dlg.DoModal()==IDOK) { strPath = dlg.GetPathName(); if(strPath.Right(4)!=".jpg") strPath += ".jpg"; if(access(strPath,0)==0) { CString strQuery; strQuery.Format("%s 已经存在,要替换掉吗?", strPath); if(IDNO==::MessageBox(m_hWnd, strQuery, "文件覆盖询问", MB_ICONQUESTION | MB_YESNO)) return; } //add own process }