I have a C # application that saves its state when it is closed, and then reads in a saved state at startup. One saved item is the location of the main form. This usually works fine - in my code there is a line like this that saves the location to a file, which is then read at startup:
streamWriter.WriteLine("location:" + this.Location.X + "," + this.Location.Y);
Typically, the location coordinates look like this on my multi-monitor machine:
location:-1069,283
Sometimes I see coordinates that are saved as follows:
location:-32000,-32000
And then, when the user returns the application back, the form goes beyond the desktop and cannot (easily) be received by the average user.
What happens to make the coordinates read this way, and are there any suggestions to prevent this from happening?
Dave source share