I have data stored in a CString
and it needs to be parsed by an XML parser library. The problem is the XML parser takes in a CFile
. It's not ideal to write out the CString
to a text file and the开发者_JAVA百科n reload it into a CFile
. Is there any way to directly send the CString
to the CFile
without making an intermediate output file?
You should be able to use CMemFile to accomplish this. It inherits from CFile
and allows you to specify an arbitrary buffer for data. The following sample code should work:
CString strData;
CMemFile memFile( (BYTE*)strData.GetBuffer() , (strData.GetLength() + 1) * sizeof(TCHAR) );
//Do something with memFile
strData.ReleaseBuffer();
精彩评论