MFC Problem with writing file
-
Hello , I use this section to write some code in a file f.Open(_T("file.log"), CFile::modeNoTruncate | CFile::modeWrite); if(f!=f.hFileNull) { f.SeekToEnd(); } else { f.Open(szFilename, CFile::modeCreate | CFile::modeWrite); } CArhive arStore(&f, CArchive::store); arStore.WriteString(_T("message"); It works fine like this. But I want to make a class that writes the file. In .h I have : private: CFile f; CArchive arStore; And I have a method to write an open file. I encounter a problem in constructing the arStore object. (ERROR: CArchive not apropiate default constructor available) This like is the problem : arStore(&f, CArchive::store); I think that there is a method like Open for CFile but I don't find it. Tnx for the help
-
Hello , I use this section to write some code in a file f.Open(_T("file.log"), CFile::modeNoTruncate | CFile::modeWrite); if(f!=f.hFileNull) { f.SeekToEnd(); } else { f.Open(szFilename, CFile::modeCreate | CFile::modeWrite); } CArhive arStore(&f, CArchive::store); arStore.WriteString(_T("message"); It works fine like this. But I want to make a class that writes the file. In .h I have : private: CFile f; CArchive arStore; And I have a method to write an open file. I encounter a problem in constructing the arStore object. (ERROR: CArchive not apropiate default constructor available) This like is the problem : arStore(&f, CArchive::store); I think that there is a method like Open for CFile but I don't find it. Tnx for the help
mihai123 wrote:
I encounter a problem in constructing the arStore object. (ERROR: CArchive not apropiate default constructor available)
You can use the Initialization list. eg:
class Test
{private:
CFile f;
CArchive arStore;
public:
Test():arStore(&f, CArchive::store)
{
};
};nave [OpenedFileFinder]
-
mihai123 wrote:
I encounter a problem in constructing the arStore object. (ERROR: CArchive not apropiate default constructor available)
You can use the Initialization list. eg:
class Test
{private:
CFile f;
CArchive arStore;
public:
Test():arStore(&f, CArchive::store)
{
};
};nave [OpenedFileFinder]