I have a C# application that saves its state when it is closed and then reads in the saved state when it starts up. One item that is saved is the location of the main form. Normally this works great - in my code there is a line like this that saves the location to a file that is then read back in on startup:
streamWriter.WriteLine("location:" + this.Location.X + "," + this.Location.Y);
Normally, the location coordinates look like this on my machine with multiple monitors:
location:-1069,283
Occasionally I'll see coordinates that are saved like this:
location:-32000,-32000
And then when the user brings the app back up, the form is way off the desktop and can't (easily) be retrieved by an average user.
What is happening to make the coordinates be read this way and are there suggestions to prevent this situation?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…