|
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 the CFile and CArchive 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.
|
|
|
|
|
from MSDN:
CArchive::Close
void Close( );
throw( CArchiveException, CFileException );
Remarks
Flushes any data remaining in the buffer, closes the archive, and disconnects the archive from the file. No further operations on the archive are permitted. After you close an archive, you can create another archive for the same file or you can close the file.
The member function Close ensures that all data is transferred from the archive to the file, and it makes the archive unavailable. To complete the transfer from the file to the storage medium, you must first use CFile::Close and then destroy the CFile object.
i.e. CArchive::Close does NOT close the related CFile.
perhaps your is not a CFile, but MSDN also states:
CFile( int hFile );
[...].The constructor with one argument creates a CFile object that corresponds to an existing operating-system file identified by hFile. No check is made on the access mode or file type. When the CFile object is destroyed, the operating-system file will not be closed. You must close the file yourself.
kiran.pinjarla wrote: When i am calling copy or delete fn.s after these line on that file, they return unsuccess
what are you doing?
hope that helps...
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.
|
|
|
|
|
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 before CArchive::Close .
|
|
|
|
|
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;
}
|
|
|
|
|
I think you replying to my previous reply.
Haven't you seen I've already modified it?
|
|
|
|
|
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 before CArchive:Close . Why what's the reason?
|
|
|
|
|
You are right.
|
|
|
|
|
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.
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
|
|
|
|
|
dear,
<pre></pre> tags are for posting code samples, not quotation, because you're breaking the page...
thank you
|
|
|
|
|
|
hello all
i want any widget who can rotate to carry out my function in a mfc project
thanks in advance
henry
|
|
|
|
|
Could you decipher your post for us (simple people) please...
Regards
|
|
|
|
|
Hi All,
we have developed a service which will be using ODBC Database connectiviy for fetching the data from database.when the system has restarted the service has to be started automatically...but it doesn't...it is unable to start because it is unable to find the ODBC connectivity...but once the system is started,when user starts it, it will be started....is that when the system is restarted and when it is starting the services till that time ODBC drivers are not installed?...can any one help me out regarding this
Mpk1979
|
|
|
|
|
You can set your service, depenendent on other service, that you feel need to run, for your service to start succesfully.
I dont know about database services, but you can identify by looking services explorer.
Once, set your service depend on other service, It will wait to start that service and then initiates its start process.
|
|
|
|
|
Just a thought, is your service running under Local Account?
In that case, you won't be able to connect over the network (since noone has logged on). And you wan't be able to connect to the DB (over the network).
Could this be the cause of your problem?
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Hi,
It shouldn't be the case, because Local account is not the one which is used to log in to the database.
I'm not quite certain, but MSDTC is probably what you're looking for. If you add it as dependency for your service, it should be working properly.
Regards
|
|
|
|
|
Hi
I want to convert my project into unicode enabled. so for this whether I have to convert all data type to unicode enabled or convert only those datatype that are releted to resources.
Thanks
M.Atul
|
|
|
|
|
Hi friends,
when i will debugg my project breakpoints are not setting properly.After debug i will get white color mark instead of red color.
Error message:One or more breakpoints cannot be set and have ben disabled.Program stop the execution of program.
These following setting i have done for debugger.
1)Project->setting->debug->server exe file path.
2)Project-> setting->c/c++->optimization->Disabled(debug)
3).........................-> debug info->Program database for edit and continue
After buliding i am not getting pojectname.pdb. but i am getting Old project .pdb file.I guess problem with .pdb file.I hope anybady having some idea.please share your ideas.
|
|
|
|
|
Generally, this happens, if no debug symbol loaded for code, you have set breakpoint for.
|
|
|
|
|
I have set breakpoint for one function called DocOpenOldStyle().But it doesn't matter for function.
May i know what type of setting i want to do?
|
|
|
|
|
What type of application, you are working with?
Make sure following things,
-You are using Debug configuration.
-If you are developing dll/COM add-in, its loaded in target exe correctly.
|
|
|
|
|
Hi Prasad,
Thanks for ur suggestions.
I am using Win32 appliaction, and Debug configuration.
I have loaded target exe file properly.I am sure about this things.
Inspite of these setting i am getting same error.
We are implementing new project in that Debugger is not working, but in another system Debugger is running properly. I do not understand what is the probelm?
|
|
|
|