"cannot open source file" error

Vladimir Kolmogorov 0 Reputation points
2023-07-17T06:19:47.85+00:00

I just installed Visual Studio 2022. I created a new empty project, added file "test.cpp" and tried to compile. It says "Cannot open source file ...\TEST.CPP". (Screenshots are here: test.pdf ). Following suggestions on internet, I installed "Windows SDK 10" and retargeted project. I have Windows 10 Pro (on a virtual machine). What am I doing wrong?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,888 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 29,446 Reputation points Microsoft Vendor
    2023-07-17T08:35:53.2366667+00:00

    Hello @Vladimir Kolmogorov ,

    Welcome to Microsoft Q&A forum.

    If you try to change to create a new project and save it in another directory, maybe in other drive, and then add a .cpp file, will the same error appear?

    If the same error still appears, please try to close VS > open VS Installer > More > click Repair to repair VS. Also try to run devenv /ResetSettings in VS Developer Command Prompt to reset VS settings.

    If the same error doesn’t appear, please check if there’s any limitation or special configuration on that drive/directory.

    Besides, please try to run VS as administrator.

    Best Regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.