Hallo an alle,
ich bin kein C++ Programmierer, aber ich muss ein solches Projekt supporten. Und das auch noch in MFC.
Ich habe folgendes Problem:
Ich muss eine Datei binär einlesen und dann in 2 gleichgroße Buffer aufteilen. Eigentlich kein Problem, dachte ich. Aber ich bekomme
die Datei einfach nicht eingelesen.
code:
CFile* pFile = NULL;
// Constructing a CFile object with this override may throw
// a CFile exception, and won't throw any other exceptions.
// Calling CString::Format() may throw a CMemoryException,
// so we have a catch block for such exceptions, too. Any
// other exception types this function throws will be
// routed to the calling function.
TCHAR* pszFileName = _T("C:\\Projekte\\TestC++\\Debug\\test.bin");
try
{
pFile = new CFile(pszFileName,CFile::modeRead | CFile::typeBinary);
ULONGLONG dwLength = pFile->GetLength();
CString str;
str.Format(_T("Your file %S is %I64u bytes long."), pszFileName, dwLength);
AfxMessageBox(str);
}
catch (CFileException* pEx)
{
// Simply show an error message to the user.
pEx->ReportError();
pEx->Delete();
}
catch (CMemoryException* pEx)
{
pEx->ReportError();
pEx->Delete();
// We can't recover from this memory exception, so we'll
// just terminate the app without any cleanup. Normally,
// an application should do everything it possibly can to
// clean up properly and _not_ call AfxAbort().
AfxAbort();
}
// If an exception occurs in the CFile constructor,
// the language will free the memory allocated by new
// and will not complete the assignment to pFile.
// Thus, our clean-up code needs to test for NULL.
if (pFile != NULL)
{
pFile->Close();
delete pFile;
}
Die Datei ist zwar geöffnet aber die Größe ist immer 0.
Was mach ich falsch???
Leider darf ich die Testdatei nicht uploaden. Es handelt sich um ein binäres IDTag.
Danke Torsten
ich bin kein C++ Programmierer, aber ich muss ein solches Projekt supporten. Und das auch noch in MFC.
Ich habe folgendes Problem:
Ich muss eine Datei binär einlesen und dann in 2 gleichgroße Buffer aufteilen. Eigentlich kein Problem, dachte ich. Aber ich bekomme
die Datei einfach nicht eingelesen.
code:
CFile* pFile = NULL;
// Constructing a CFile object with this override may throw
// a CFile exception, and won't throw any other exceptions.
// Calling CString::Format() may throw a CMemoryException,
// so we have a catch block for such exceptions, too. Any
// other exception types this function throws will be
// routed to the calling function.
TCHAR* pszFileName = _T("C:\\Projekte\\TestC++\\Debug\\test.bin");
try
{
pFile = new CFile(pszFileName,CFile::modeRead | CFile::typeBinary);
ULONGLONG dwLength = pFile->GetLength();
CString str;
str.Format(_T("Your file %S is %I64u bytes long."), pszFileName, dwLength);
AfxMessageBox(str);
}
catch (CFileException* pEx)
{
// Simply show an error message to the user.
pEx->ReportError();
pEx->Delete();
}
catch (CMemoryException* pEx)
{
pEx->ReportError();
pEx->Delete();
// We can't recover from this memory exception, so we'll
// just terminate the app without any cleanup. Normally,
// an application should do everything it possibly can to
// clean up properly and _not_ call AfxAbort().
AfxAbort();
}
// If an exception occurs in the CFile constructor,
// the language will free the memory allocated by new
// and will not complete the assignment to pFile.
// Thus, our clean-up code needs to test for NULL.
if (pFile != NULL)
{
pFile->Close();
delete pFile;
}
Die Datei ist zwar geöffnet aber die Größe ist immer 0.
Was mach ich falsch???
Leider darf ich die Testdatei nicht uploaden. Es handelt sich um ein binäres IDTag.
Danke Torsten
Comment