C++ file I/O

Started by
1 comment, last by Cacks 18 years ago
Hi guys, I have created methods for saving and loading my objects to and from disk. They work fine. I'm using VC++ .Net 2003, but I'm using std ifstream & ofstream. I'm wondering what kinds of exceptions can this throw? I'm especially interested in how I would find if the file intended to be loaded does not exist? How would I deal with this error. Thanks for any help given!
Reject the basic asumption of civialisation especially the importance of material possessions
Advertisement
Hey bud,

What i would do here is simply try and open the file as you prolly already are, but then immediately check the whether it is open or not, like this:
if ( myFile.is_open() ){  // blah}


I'm not particularly expereince with C++ files but i believe there is no need to worry about exceptions here. If it isn't open then it isn't open.

Hope that helps,

Dave
Hey, thanks for that!
Reject the basic asumption of civialisation especially the importance of material possessions

This topic is closed to new replies.

Advertisement