Converting VS6 project to VS2008 - CString

In my VC6 project we have a class derived from CString called CString2.  It has a convenient method that loads a file.  Here is the code:

BOOL CString2::Load(FILE* stream, long bytes)
    size_t count = fread(m_pchData, sizeof(BYTE), bytes, stream);
    return ((long)count == bytes);

The problem that I'm having is that "AllocBuffer()" is no longer implement in 2005/2008.  Since this class is used in so many places within our code, for various reasons, I have been trying to come up with a way to replace the contents of the above method so as to not have to replace the entire class everywhere it's used.  I'm not that familiar with 2008 so any help would be GREAT!

Craig Schmidtsoftware EngineeringAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Actually you need to reserve a memory block that will be big enough to load the file.
I think this file is a text (because you load it into a string class).
So, firstly CString has AllocSysString method, it's for BSTR and, I think, you can use it too.
Also CString has Insert method that allow you to insert any other string.
Also you can load the file into a WCHAR or char buffer and use the CString assignment operator to store the data into your class.

The correct way was to make a helper class, simply a function, that load the data from the file into a buffer (or into your class).

Pay attention on GetBuffer and Release

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Craig Schmidtsoftware EngineeringAuthor Commented:
Thanks pgnatyuk.  I'll give your suggestions a try.

You are welcome
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.