"Error C1083: Cannot open source file" Shouldn't Be Looking For The File At All

When I ran across a similar problem with VS Express, I wound up having to open up the the .vcxproj file (which is just XML), and remove the offending < ClInclude Include="FILEPATHANDNAME" > tags.

OK, I have no idea how I did it but I'm still going to try to write what I did.

  1. Save all and Close solution
  2. Open the .vcxproj file (not .sln)
  3. Build -> Clean [Project Name]
  4. Save all and Close
  5. Open the .sln file again.
  6. Build -> Project Only -> Clean Only [Project Name]
  7. Build -> Project Only -> Build Only [Project Name]

That's exactly what I did and worked for me. I think the main thing to do is clean, save, close, open, build, but I'm not sure.

In Solution Explorer you can select/deselect option "Show All Files". Try both options and make sure excluded file is not included in project for both of them.

That's what I had: I used "Show All Files" option (so you can see all the files in project directories). I excluded one of my .cpp files from project. However, it behaved as this file is in project.

That's how I managed to fix it: I switched "Show All Files" off and saw this file still belongs to project! So I excluded this file once again.

As I see, that's a known issue.

This worked for me, hope it will be useful for someone else.