本文整理汇总了C++中CFileException::ReportError方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileException::ReportError方法的具体用法?C++ CFileException::ReportError怎么用?C++ CFileException::ReportError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileException
的用法示例。
在下文中一共展示了CFileException::ReportError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnBnClickedLoadbtn
void CTextPadDlg::OnBnClickedLoadbtn()
{
// TODO: Add your control notification handler code here
char szFilter[] = "(*.txt) | All Files(*.*)|*.*||";
CFileDialog dlg(TRUE, "txt", "*.txt", OFN_HIDEREADONLY, szFilter);
if(IDOK == dlg.DoModal()){
CString strPathName = dlg.GetPathName();
CStdioFile fp;
CFileException e;
if(!fp.Open(strPathName, CFile::modeRead, &e)) {
e.ReportError();
return;
}
CString str = "";
CString tmp = "";
while(fp.ReadString(tmp)){
str += tmp;
str += "\r\n";
}
UpdateData(FALSE);
textpad.SetWindowText(str);
fp.Close();
}
}
示例2: OnBnClickedSavebtn
void CTextPadDlg::OnBnClickedSavebtn()
{
// TODO: Add your control notification handler code here
//CFileDialog를 숨긴파일 읽지않고,
//같은 이름의 파일이 있을시 물어보는 옵션으로 열기
char szFilter[] = "(*.txt) | All Files(*.*)|*.*||";
CFileDialog dlg(FALSE, "txt", "*.txt",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT , szFilter);
if(IDOK == dlg.DoModal()){
CString strPathName = dlg.GetPathName();
CStdioFile fp;
CFileException e;
if(!fp.Open(strPathName,CFile::modeWrite|CFile::modeCreate, &e)) {
e.ReportError();
return;
}
UpdateData(TRUE);
CString str;
textpad.GetWindowText(str);
str.Replace("\r\n", "\n");
fp.WriteString(str);
fp.Close();
}
}
示例3: convert_all_file
void CKmlDlg::convert_all_file()
{
int i;
CString temp;
for(i=0;i<NumOfFile;i++)
{
CFileException ef;
try
{
if(!Fsource.Open(FilePath[i],CFile::modeRead,&ef))
{
ef.ReportError();
continue;
}
IsFSourceOpen = true;
kml_filename = FileName[i];
int find = kml_filename.Find(".");
kml_filename = kml_filename.Mid(0,find);
Convert();
temp.Format("%s OK",FileName[i]);
m_check[i].SetWindowText(temp);
m_check[i].SetCheck(BST_CHECKED);
}
catch(CFileException *fe)
{
fe->ReportError();
fe->Delete();
}
}
}
示例4: Save
bool CCrossDlg::Save(int Sel)
{
ASSERT(Sel >= 0 && Sel < SELS);
CPathStr FileName;
GetName(Sel, FileName);
CFileDialog fd(FALSE, EXT_PATCH, FileName, OFN_OVERWRITEPROMPT, LDS(IDS_FILTER_PATCH));
if (fd.DoModal() != IDOK)
return(FALSE);
CStdioFile fp;
CFileException e;
if (!fp.Open(fd.GetPathName(), CFile::modeCreate | CFile::modeWrite, &e)) {
e.ReportError();
return(FALSE);
}
CPatch Patch;
Patch = m_Info[Sel]; // assign parm info
m_Frm->GetPatch(Patch); // get master and main info
if (!Patch.Write(fp))
return(FALSE);
m_Modified[Sel] = FALSE;
FileName = fd.GetFileName();
FileName.RemoveExtension();
SetName(Sel, FileName);
return(TRUE);
}
示例5: DoIO
bool CJobList::DoIO(LPCTSTR Path, DWORD FileMode, DWORD ArchiveMode)
{
CFile fp;
CFileException e;
if (!fp.Open(Path, FileMode, &e)) {
e.ReportError();
return(FALSE);
}
TRY {
CArchive ar(&fp, ArchiveMode);
ar.m_strFileName = fp.GetFileName();
Serialize(ar);
}
CATCH(CArchiveException, e)
{
e->ReportError();
return(FALSE);
}
示例6: Read
bool CPatch::Read(LPCTSTR Path)
{
CStdioFile fp;
CFileException e;
if (!fp.Open(Path, CFile::modeRead | CFile::shareDenyWrite, &e)) {
e.ReportError();
return(FALSE);
}
TRY {
if (!Read(fp)) {
AfxMessageBox(IDS_DOC_BAD_FORMAT);
return(FALSE);
}
}
CATCH(CFileException, e)
{
e->ReportError();
return(FALSE);
}
示例7: convert_all_file
void CKmlDlg::convert_all_file()
{
int i;
CString temp;
CKmlDlg::kmlDlg->PostMessage(UWM_PROGRESS, 1, 0); //Show progress
for(i = 0; i < NumOfFile; ++i)
{
CFileException ef;
CFile f;
try
{
if(KML_USE_CHECKLISTBOX)
{
m_fileList.SetCurSel(i);
}
if(!f.Open(FilePath[i], CFile::modeRead,&ef))
{
ef.ReportError();
continue;
}
kml_filename = FilePath[i];
int find = kml_filename.ReverseFind('.');
kml_filename = kml_filename.Mid(0,find);
//Convert(f);
Convert2(f);
f.Close();
temp.Format("%s OK", FileName[i]);
if(KML_USE_CHECKLISTBOX)
{
//m_fileList.SetCurSel(i);
m_fileList.DeleteString(i);
m_fileList.InsertString(i, temp);
m_fileList.SetCheck(i, BST_CHECKED);
}
else
{
m_check[i].SetWindowText(temp);
m_check[i].SetCheck(BST_CHECKED);
}
}
catch(CFileException *fe)
{
fe->ReportError();
fe->Delete();
}
}
CKmlDlg::kmlDlg->PostMessage(UWM_PROGRESS, 0, 1000); //Hide progress
}
示例8: Open
BOOL Driver::Open(LPCTSTR filename,CStdioFile &File,UINT nOpenFlags)
{
CFileException ex;
if (!File.Open(filename,nOpenFlags))
{
ex.ReportError();
return FALSE;
}
else
{
return TRUE;
}
}
示例9: Open
//************************************
// Method: Open
// FullName: CRawFileExporter::Open
// Access: public
// Returns: int
// Qualifier:
// Parameter: CString in_szFilePath
//************************************
int CRawFileExporter::Open( CString in_szFilePath )
{
int ret = SV_NORMAL;
m_szFilePath = in_szFilePath;
CFileException ex;
BOOL bflagOpen = m_oFile.Open(m_szFilePath, CFile::modeWrite | CFile::modeCreate, &ex);
if(!bflagOpen)
{
ret = SV_FILEIO_ERROR;
ex.ReportError();
m_szFilePath = _T("");
}
return ret;
}
示例10: Load
BOOL CImportFile::Load(const TCHAR *filename)
{
ASSERT( m_pDesign == NULL );
CFile f;
CFileException e;
if( !f.Open( filename, CFile::modeRead, &e ) )
{
e.ReportError();
return FALSE;
}
CArchive ar( &f, CArchive::load );
m_pDesign = new CTinyCadMultiDoc;
m_pDesign->Serialize( ar );
return TRUE;
}
示例11: DumpResourceToFile
BOOL helper::DumpResourceToFile(LPCSTR lpName, LPCSTR lpType, LPCSTR lpFile)
{
HRSRC hrsRC = ::FindResource(NULL, lpName, lpType);
HGLOBAL hGlobal = ::LoadResource(NULL, hrsRC);
LPVOID pData = ::LockResource(hGlobal);
DWORD dwLen = ::SizeofResource(NULL, hrsRC);
CFile f;
CFileException e;
if (!f.Open(lpFile, CFile::modeCreate | CFile::modeWrite, &e))
{
e.ReportError();
return FALSE;
}
f.Write(pData, dwLen);
f.Close();
return TRUE;
}
示例12: Load
/**
* Load the coding file
*/
void CCoding::Load()
{
Clear();
CFileFind finder;
if (finder.FindFile(m_Filename)) {
finder.Close();
} else {
if (!SaveRes(m_Filename)) {
ShowError(_T("Can't find encoding file \"") + m_Filename + _T("\""));
return;
}
}
CFileException ex;
CFile f;
if (f.Open(m_Filename, CFile::modeRead | CFile::shareDenyWrite, &ex)) {
char c;
CString line;
while (f.Read(&c, 1)) {
switch (c) {
case 10:
break;
case 13:
if (!line.IsEmpty()) {
AddCode(line);
line.Empty();
}
break;
default:
line += c;
}
}
f.Close();
if (!line.IsEmpty()) {
AddCode(line);
}
} else
ex.ReportError();
m_Loaded = TRUE;
}
示例13: OnBvecButton
void ToolWnd::OnBvecButton()
{
CMainFrame * pFrame = (CMainFrame *) AfxGetApp()->m_pMainWnd;
CString szFilter = _T("B-vector table (*.txt)|*.txt| All Files (*.*)|*.*|");
CFileDialog dlg (TRUE, NULL, NULL, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT, szFilter, this);
if(dlg.DoModal() == IDCANCEL)
return;
CStdioFile file;
CFileException e;
CString str, temp;
int i = 0;
if(!file.Open(dlg.GetPathName() , CFile::modeRead, &e))
{
e.ReportError();
return;
}
for (int i =0; i <3; i++)
{
for(int j =0; j <15; j++)
{
if(file.ReadString(str))
{
AfxExtractSubString(temp,str, 0,'\n');
BV[i][j] =_ttof(temp);
}
}
}
file.Close();
AfxMessageBox(_T("Complete Load B-vec"));
}
示例14: Open
bool CCrossDlg::Open(int Sel, LPCTSTR Path)
{
ASSERT(Sel >= 0 && Sel < SELS);
if (!SaveCheck(Sel))
return(FALSE);
CStdioFile fp;
CFileException e;
if (!fp.Open(Path, CFile::modeRead | CFile::shareDenyWrite, &e)) {
e.ReportError();
return(FALSE);
}
CPatch Patch;
if (!Patch.Read(fp))
return(FALSE);
m_Info[Sel] = Patch;
UpdateMix(m_PosEdit.GetVal());
CPathStr FileName(PathFindFileName(Path));
FileName.RemoveExtension();
SetName(Sel, FileName);
if (Sel == m_Frm->GetEditSel()) // if input is selected for editing
m_Frm->SetEditSel(Sel); // refresh parameters dialog
return(TRUE);
}
示例15: OnBnClickedOk
void CGetEphemerisDlg::OnBnClickedOk()
{
m_file.GetWindowText(m_fileName);
if(m_fileName.IsEmpty())
{
AfxMessageBox("Please create a new file to save Ephemeris data!");
return;
}
if(Utility::IsFileExist(m_fileName))
{
AfxMessageBox("File already exist!");
return;
}
CFileException ef;
try
{
if(!CGPSDlg::gpsDlg->m_ephmsFile.Open(m_fileName, CFile::modeReadWrite|CFile::modeCreate, &ef))
{
//CGPSDlg::gpsDlg->m_ephmsFile.Close();
ef.ReportError();
return;
}
}
catch(CFileException *fe)
{
fe->ReportError();
fe->Delete();
return;
}
g_SV = m_ephems.GetCurSel();
AfxBeginThread(GetEphmsThread, (void*)ephType);
OnOK();
}