tags:

views:

40

answers:

2

Hi,

What's the best way to tell my application that the file has been modified and that it should ask the user for a filename? Is there a class for that or do I write that all that logic by hand?

Thanks!

+2  A: 

You'll need to handle that logic by hand. It's not too difficult if you've got a decent application architecture working for you. Just flip a Modified flag on your "file" object that gets serialized to disk whenever the object is mutated.

Greg D
A: 

Another solution is something I've seen recently. If setting a modified flag on your 'file' object is difficult, you could always try saving to a memory stream and calculating a hash on it, and if the hash is different to the original version's hash, it has changed.

It's not as elegant as setting a modified flag, but is much easier to retrofit.

Nick R
Another way is if your app has an undo/redo stack. Having at least one element in your undo stack means you've modified the scene. But it does require every action in the application be undoable.
Steve the Plant