views:

1320

answers:

2

First Post!

So I'm working on Windows Mobile application for a class I'm in. We have a user's data being serialized to an XML file, which is working great. But I was wondering if there's a way to tell whenever a user quits the application(by clicking the X in the top right) so I can commit the changes to the XML file at the end of the application rather than serializing after each change made. Thanks in advance for any help!

+1  A: 

You can catch the form closing event and put your save code in there.

Dan Fuller
In Windows Mobile Applications do not exit, but minimize when the user presses the X button. Deactivate and and not Closing event is fired.
kgiannakakis
You can set the form to close rather than minimise by changing to MinimiseBox property of the form to false, which I assume he has done if the application is exiting.
Dan Fuller
Didn't know it was going to be so easy. I should've noticed it in the Events list! Thanks!
Russak
No worries! Keep in mind that this is fine for a class project, however for real world apps you don't only want to save on program exit. If the user works for an hour entering data and loses power/app crashes then they'll lose all of their work.
Dan Fuller
+1  A: 

I recommend reading this article.

kgiannakakis