| | |
File not closing
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2006
Posts: 22
Reputation:
Solved Threads: 1
Hi all,
This is my problem:
The function DoIt() makes use of a DLL. Now heres the problem:
When there is an exception thrown by the DLL, I should say the
mFileOut should always be closed but it doesn't. I can't delete
the outputfile until I close my application because it says the
file is still open.
It only closes in the 'Debug Build' but not in the 'Release Build'.
Anyone has an idea ??
I use the Borland Developer Studio 2006.
This is my problem:
C++ Syntax (Toggle Plain Text)
void StartRun( void ) { std::auto_ptr<Validate> val ( new Validate( "input.txt" ) ); val->DoIt( ); } // Destructor Validate::~WValidate( ) { if( mFileIn.is_open()) { mFileIn.close(); } if( mFileOut.is_open() ) { mFileOut.flush(); mFileOut.close(); } }
The function DoIt() makes use of a DLL. Now heres the problem:
When there is an exception thrown by the DLL, I should say the
mFileOut should always be closed but it doesn't. I can't delete
the outputfile until I close my application because it says the
file is still open.
It only closes in the 'Debug Build' but not in the 'Release Build'.
Anyone has an idea ??
I use the Borland Developer Studio 2006.
Can you not catch all exceptions from DoIt ?
My guess is that your program is crashing sooooo bad that the destructor is not getting called, the program is just dumping back to the os without doing any cleanup. You really need to find out what is causing the exception and fix it. Lacking that you should implement exceptions (try/catch blocks) as ithelp suggested.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Sep 2006
Posts: 22
Reputation:
Solved Threads: 1
•
•
•
•
My guess is that your program is crashing sooooo bad that the destructor is not getting called, the program is just dumping back to the os without doing any cleanup. You really need to find out what is causing the exception and fix it. Lacking that you should implement exceptions (try/catch blocks) as ithelp suggested.
It's still a fact that in the 'Debug Build' the destructor is called, and the file can be deleted, but in the 'Release Build' it isn't.
So suggestions are still welcome....
![]() |
Similar Threads
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- Doesn't open for file input successfully.... why? (C++)
- Can someone debug my program??? (C)
- Application Data Folder... (Viruses, Spyware and other Nasties)
- Read This - It Might Help Someone! (Windows NT / 2000 / XP)
- HijackThis error? (Viruses, Spyware and other Nasties)
- Woe is Me (Viruses, Spyware and other Nasties)
- Zend PHP Certification (PHP)
- Syntax for deleting specified file ( in C++) (C++)
Other Threads in the C++ Forum
- Previous Thread: one loop to perform 2 things
- Next Thread: Problem with static STL i.e. map
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph homeworkhelp iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






