CArchive::Close()
-
Thank you capallini. But if i call fp.Close() after ar.Close() i am getting an expection.
KIRAN PINJARLA
You need to call
CFile::Close
beforeCArchive::Close
.Prasad Notifier using ATL | Operator new[],delete[][^]
-
You need to call
CFile::Close
beforeCArchive::Close
.Prasad Notifier using ATL | Operator new[],delete[][^]
prasad_som wrote:
You need to call CFile::Close before CArchive::Close.
You are wrong. CArchive does not close the file object. This is the source code...
void CArchive::Close()
{
ASSERT_VALID(m_pFile);Flush(); m\_pFile = NULL; // --> Just detaches the file pointer that's all, but doesn't close
}
Nibu thomas A Developer Programming tips[^] My site[^]
-
prasad_som wrote:
You need to call CFile::Close before CArchive::Close.
You are wrong. CArchive does not close the file object. This is the source code...
void CArchive::Close()
{
ASSERT_VALID(m_pFile);Flush(); m\_pFile = NULL; // --> Just detaches the file pointer that's all, but doesn't close
}
Nibu thomas A Developer Programming tips[^] My site[^]
I think you replying to my previous reply. Haven't you seen I've already modified it?
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Thank you capallini. But if i call fp.Close() after ar.Close() i am getting an expection.
KIRAN PINJARLA
Since the following snipped of code works fine on my system:
CFile file; MyObject obj; file.Open("foo.txt",CFile::modeWrite|CFile::modeCreate); CArchive ar(&file, CArchive::store); obj.Serialize(ar); ar.Close(); file.Close();
hope that helps. :confused:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
I think you replying to my previous reply. Haven't you seen I've already modified it?
Prasad Notifier using ATL | Operator new[],delete[][^]
prasad_som wrote:
I think you replying to my previous reply. Haven't you seen I've already modified it?
No I didn't see but still why are you saying that
CFile::Close
should be called beforeCArchive:Close
. Why what's the reason?
Nibu thomas A Developer Programming tips[^] My site[^]
-
prasad_som wrote:
I think you replying to my previous reply. Haven't you seen I've already modified it?
No I didn't see but still why are you saying that
CFile::Close
should be called beforeCArchive:Close
. Why what's the reason?
Nibu thomas A Developer Programming tips[^] My site[^]
:doh: You are right.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Since the following snipped of code works fine on my system:
CFile file; MyObject obj; file.Open("foo.txt",CFile::modeWrite|CFile::modeCreate); CArchive ar(&file, CArchive::store); obj.Serialize(ar); ar.Close(); file.Close();
hope that helps. :confused:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
Yes. I was wrong. It was not this fp.Close() which was causing the exception. It was another Close(). Anyhow learned a few new things. Thank you all.
KIRAN PINJARLA
-
kiran.pinjarla wrote:
if ar.Close() is called does it close the file pointer associcated with it(fp.Close)?
Yes, it does close CArchive. But not the CFile associated with it.
kiran.pinjarla wrote:
When i am calling copy or delete fn.s after these line on that file
What are these function ? of which class? -- modified at 3:33 Thursday 30th November, 2006 -- modified at 4:59 Thursday 30th November, 2006
Prasad Notifier using ATL | Operator new[],delete[][^]
prasad_som wrote:
You need to call CFile::Close before using CArchive::Close
In my opinion the file must be closed after closing the archive. Otherwise it will be impossible to flush the last data kept in an internal buffer of
CArchive
. If theCFile
andCArchive
objects are created on the stack, then they will be closed automatically in right order. -
prasad_som wrote:
You need to call CFile::Close before using CArchive::Close
In my opinion the file must be closed after closing the archive. Otherwise it will be impossible to flush the last data kept in an internal buffer of
CArchive
. If theCFile
andCArchive
objects are created on the stack, then they will be closed automatically in right order.Viorel. wrote:
In my opinion the file must be closed after closing the archive
You are right.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
dear, <pre></pre> tags are for posting code samples, not quotation, because you're breaking the page... thank you ;)
You don't know where to start ? ask a good friend
OK, dear... :):-D:) but what does it mean because you're breaking the page...? I cannot understand :confused:, please explain to me. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.