17 Dec 2009

In Visual C# 2008 Express, Save doesn't always save your work

The most important thing I learned in all these years using computers is to save my work often. Very often. Hardware and software, no matter on which OS, have a tendency to stop working just when you're in the middle of editing some large and important document. That's why I always save after almost every sentence. (The Blogger editor saves automatically and often too, I noticed, which I appreciate a lot.)

In Visual C# Express however, often saving turns out to be not always enough. I created a new project, added some files to it, assuming they would be saved in the normal project location (My documents\Visual Studio 2008\Projects). I fooled around a bit with the project, ran it a few times, added more files, fooled around some more, edited my files, clicked Save File a lot, ran my application a few times, debugged it, and this went on for the whole afternoon. Then I tried to resize a panel in a form and something went wrong: Visual C# Express crashed. No problem, I thought, I've saved all my work until that last fatal change. So I relaunched Visual C# Express, clicked "Open project" and then, to my dismay, I could not see my project!
I launched Windows Explorer, searched around, but could not find my recently created C# files. Also tried the find command, but no use. It seemed all my files from the new project were gone.

I searched the web for people who had a similar experience and then found this post. It mentioned that I could maybe find my files in some temporary folder, but that turned out to be not the case. The post explains that this is sort of a feature of Visual C# Express (the post refers to Visual C# Express 2005, but the feature was apparently succesful enough to keep it in the 2008 version):  the project and its files aren't actually saved in My Documents until you explicitly do Save Project. Until then, Save File doesn't really save your files in the truest sense of the word, it merely stores them temporarily.

This "impact-less projects" feature is the most curious one I've ever seen in any product. Luckily it can be switched off somewhere in the settings, but I only discovered that after losing an afternoon of work.