Windows10下Visual Studio2017编写C程序找不到指定exe文件求助
Hey there, let's work through that "file not found" error you're facing in Visual Studio 2017. Since you've already ruled out obvious code compilation errors, let's dive into other common fixes that often resolve this issue:
Sometimes Visual Studio fails to generate the .exe even if your code has no squiggly red errors. Head to the Output window (go to View > Output, then select "Build" from the dropdown menu at the top of the window) and scan for any warnings or errors that popped up during the build process. Things like missing system dependencies, folder permission issues, or corrupted project files can silently block the exe from being created. If you spot errors here, tackle those first—for example, if you see a "permission denied" message, try launching VS2017 as Administrator.
Corrupted intermediate build files are a super common culprit here. Let's wipe them and start fresh:
- Go to
Build > Clean Solutionto delete all existing build artifacts. - Then select
Build > Rebuild Solutionto force a full recompile and re-link of your project. This ensures no leftover, broken files are messing with the build process.
Make sure your project is configured to output the .exe exactly where the error says it's looking:
- Right-click your project in the Solution Explorer > Properties.
- Navigate to
Configuration Properties > Generaland check the "Output Directory" field. It should match the path in the error:C:\Users\XXXX\source\repos\TestingProject\Debug\. If it doesn't, update it and rebuild. - Also check
Configuration Properties > Linker > Output File—it should be set to$(OutDir)$(TargetName)$(TargetExt)(this is the default setting that points to the Debug folder's exe).
- Navigate to
C:\Users\XXXX\source\repos\TestingProject\and see if theDebugfolder exists. If it's missing, create it manually, then try rebuilding your project. - If the folder is there, right-click it > Properties > Security and confirm your user account has "Write" permissions. If not, add write access for your account and apply the changes.
Corrupted project settings can break the build pipeline. Try these steps:
- Right-click your project in Solution Explorer > Unload Project.
- Right-click the unloaded project > Edit TestingProject.vcxproj. Look for any odd XML entries (like incorrect file paths). If you're unsure, you can create a new empty C project, copy its
.vcxprojcontent, and replace your project's content (just make sure to back up your original file first!). - Alternatively, go to
Tools > Import and Export Settings > Reset all settingsto restore VS2017 to its default configurations.
Some antivirus tools block Visual Studio from creating or accessing executable files in the Debug folder. Try temporarily disabling your antivirus, then rebuild and run the project. If it works, add the Debug folder to your antivirus' exclusion list to prevent future issues.
If you still hit the same error after trying all these steps, sharing the full build output from the Output window would help narrow down the problem further.
内容的提问来源于stack exchange,提问作者my7h

