Hi!

I used these lines of code to read a text file into a CString-object:

CString cstrFileBuffer;
LPSTR lpstrFileBuffer;
DWORD dwFileLength;
lpstrFileBuffer = cstrFileBuffer.GetBuffer ();

CFile file (cstrFileName, CFile::modeRead);
dwFileLength = file.GetLength ();
file.Read (lpstrFileBuffer, dwFileLength);
cstrFileBuffer.ReleaseBuffer ();

Well, this works in my case, but i was wondering if the GetBuffer()-function
does allocate the memory when calling it (without initializing the CString).
If not i might get some problems later on...

Can anybody tell me a more elegant and/or safer way to read in a text-file?!