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
Reloading a file that has changed during the duration of the program
quote: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]
The file won''t be changed until the buffer is flushed. That occurs automatically when you insert an
endl
or when you use the flush method.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement