Visual studio file opens only with notepad

Bartolinio picture Bartolinio · Nov 1, 2011 · Viewed 13.4k times · Source

I have a very strange issue with Visual Studio 2010.

My program have some memory issues, so I have to reboot frequently. After the last reboot, one of my header files has been corrupted automatically, and can be opened now only by notepad (even from the internal environment of Visual Studio, while debuuging (it only shows me only the assembly code) or when I go to this file's folder and do "Open with Visual Studio", its still notepad that opens it).

I found the problem in the Microsoft Forums, but there isn't any idea for solution there.

Answer

Sammler picture Sammler · Jan 28, 2015

I recently had the same problem. I believe the file is corrupted with non-printing characters; it looks fine in Notepad except every line is indented by one space.

To resolve the issue, I had to open the file in notepad, then remove/delete the original, recreate it by adding a new item to the project, and copy in the contents of the old file from Notepad.

I am using VS Express 2013, which imposes its own formatting on pasted-in text, so the indentation disappeared at this point. Mercurial doesn't show any diffs between the corrupted and new files (except for some code I just added).