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

Reloading a file that has changed during the duration of the program

This topic is 5304 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

I noticed that if I use an ifstream to load a file, and then another program changes the file, and I close the file and open it again, it still loads the original file. I even tried making a pointer to an ifstream and then deleting it and recreating it, but I still couldn''t get the behavior I wanted. Is there some workaround or something dumb that I''m missing(the latter is far more likely )? 404x3

-~-The Cow of Darkness-~- If you see the image I am online

Share this post

Link to post
Share on other sites
Original post by Hollower
Close the file *before* the other program opens it.

Ahh! That's something to try! I would deny access to the file from other programs, but that would defeat the purpose of my little project.

EDIT: OK, that worked, but I'm not sure that was the main problem. It seems that when the other program modifies the file, the file doesn't actually change... I'm creating an ofstream called in, oppening the file in ios::append, and using in >> "whatever"... this should be quite a bit easier to fix... I hope. Thanks!

[edited by - cowsarenotevil on June 4, 2003 9:27:43 PM]

Share this post

Link to post
Share on other sites