I just started working on a small tool to search for (heavy) text files using Visual
C++ with MFC.
Because there are a lot of readings, I'm wondering if ifstream of the standard
library is better than CFile of MFC?
I don't need portability (the program is for Windows Environment), so I don't see
any advantages of ifstream over CFile? However, with little experience with MFC I'm not
certain if the performance of CFile is better or worse than ifstream? I doubt that replacing CFile with ifstream will do much in terms of performance improvement but I still want to ask you guys' opinions on this.

Thank you very much

7 Years
Discussion Span
Last Post by paddy8788

Depends on the file and its contents. CFile is not a good choice for reading strings (standard text files) unless you also want to use CArchive and CString. If you don't have to serialize MFC classes then I would use standard c++ fstream


Thank you very much!
I replaced CFile with ifstream and indeed the performance is significantly improved (about 15% search time is saved).

Well, Microsoft should've mentioned the performance difference in their documentation lol

Edited by paddy8788: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.