CFile::Open within an ActiveX ?
I have the following code within an ActiveX control and it crashes the TestContainer every time.
CFile f;
CFileException e;
TCHAR* pFileName = _T("c:\\tree.txt");
f.Open(pFileName, CFile::modeRead | CFile::shareDenyWrite, &e);
The "tree.txt" file is in the "c:\" directory.
Is there another way I should be doing file reading from within an ActiveX control?
Any help would be greatly appreciated.
Thanks. Pete
Re: CFile::Open within an ActiveX ?
I forgot to mention the error I get is:
3e6 : "Invalid access to memory location"
Re: CFile::Open within an ActiveX ?
use ifstream C++ class, or fread().
Please - rate answer if it helped you
It gives me inspiration when I see myself in the top list =)
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com
Member of Russian Software Developer Network http://rsdn.ru
Re: CFile::Open within an ActiveX ?
Quote:
Originally Posted by
pdcira
I have the following code within an ActiveX control and it crashes the TestContainer every time.
CFile f;
CFileException e;
TCHAR* pFileName = _T("c:\\tree.txt");
f.Open(pFileName, CFile::modeRead | CFile::shareDenyWrite, &e);
The "tree.txt" file is in the "c:\" directory.
Is there another way I should be doing file reading from within an ActiveX control?
Any help would be greatly appreciated.
Thanks. Pete
Shouldn't this line...
TCHAR* pFileName = _T("c:\\tree.txt");
only have one backslash?
TCHAR* pFileName = _T("c:\tree.txt");
Perhaps that would work better?
Re: CFile::Open within an ActiveX ?
Quote:
Originally Posted by
HarveyURAD
Shouldn't this line...
TCHAR* pFileName = _T("c:\\tree.txt");
only have one backslash?
TCHAR* pFileName = _T("c:\tree.txt");
Perhaps that would work better?
No! \ is the escape char in strings so to actually have a \ in a string you use \\. See http://msdn.microsoft.com/en-us/library/6aw8xdf2.aspx
Re: CFile::Open within an ActiveX ?
Quote:
Originally Posted by
2kaud
Ah! You are absolutely correct, my mistake ;)