Advertisement Jump to content


This topic is now archived and is closed to further replies.


CFile in MSVC++ is MFC only?

This topic is 6179 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

After FILE *fp failed to deliver the goods, I was looking for an alternative. I came accross CFile (MSVC++6) which could do what I want without complication. I tried using it in my Win32 DirectX program, but it failed to compile as it required the afx.h header file. I included this file, but then it told me that Windows.h cannot be included in MFC applications! Is CFile specifically for MFC apps, or can I trick the compiler and use CFile without MFC? At the moment I''m using FILE *fp but it takes ages to truncate a huge 40MB file since I have to use a temp file

Downloads, D3DXSprite tutorial, New platform game: .-= The ZeroOne Realm =-.

Share this post

Link to post
Share on other sites
CFile is just a wrapper around ANSI''s FILE. Or, more precice, they both resolve to Win32s API CreateFile, ReadFile, etc. So there''s no perfomance benefit using one or another.
And yes, CFile is a part of MFC - use it all or nothing.

Share this post

Link to post
Share on other sites
Any wrapper will degrade performance, though it''s usually trivial and practically immesureable.

There''s no real problem with not being able to include Windows.h. If you need to do things like set WINVER or whatever, do that before you include afx.h.

I can''t imagine why using the C library functions wouldn''t have worked for you. If you can''t handle that, I can''t imagine how you''ll do much better with CFile, anyway. If your project is C++, maybe try ifstream and ofstream. But that will incurr overhead as well.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!