问题描述
所以我在尝试使用 CodeBlocks 编译 C++ 代码时不断收到此错误.
So I keep getting this error when trying to compile C++ code using CodeBlocks.
无法打开输出文件 [filename.exe] 权限被拒绝
cannot open output file [filename.exe] permission denied
它今天才开始,而且是零星的和不一致的.如果我关闭 CodeBlocks 并重新启动项目,它通常会消失,但并非总是如此.有时,当我多次按 F9(构建和运行)时,它甚至会消失.我总是检查任务管理器,但从来没有任何 .EXE 以我的文件名或与之相关的任何内容运行.
It only started today, and it's sporadic and inconsistent. It usually goes away if I shut CodeBlocks down and restart the project, but not always. Sometimes it even goes away when I just press F9 (build & run) several times. I always check Task Manager, but there are never any .EXEs running with my file's name, or anything related to it.
我还注意到,如果出现此问题,然后我尝试手动删除 .EXE 或以其他方式与之交互,Windows 会告诉我我需要管理员权限才能这样做(这是一台私人 PC,就我知道我是它的管理员).
I've also noticed that if this problem occurs and I then try to delete the .EXE manually or otherwise interact with it, Windows tells me I need administrator permission to do so (this is a private PC, and as far as I know I am an administrator on it).
第一次发生时,我在代码中添加的唯一内容是发送给 cout 的调试报告——几乎没有什么神秘的东西.有时即使没有更改以前版本的代码也会发生这种情况.
The first time it occurred, the only thing I had added to the code beyond what was in the previous version was a debugging report sent to cout - hardly anything arcane. It sometimes occurs even when no code was changed from a previous version.
这会是什么?这还没有破坏游戏规则,但很烦人,我宁愿它不要变得更糟.
What could this be? It's not game-breaking, yet, but it's irritating and I'd rather it didn't get worse.
这已经很旧了,但以防万一其他人遇到类似问题,我目前使用的解决方法只是在尝试再次运行代码之前始终删除 [filename.exe].这避免了这个问题,尽管它很烦人.
This is old by now, but just in case anyone else is having similar problems, the workaround I currently use is just to consistently delete [filename.exe] before trying to run the code again. This avoids the problem, though it is annoying.
推荐答案
检查filename.exe"没有运行,我猜您使用的是 Microsoft Windows,在这种情况下,您可以使用任务管理器或进程资源管理器:http://technet.microsoft.com/en-us/sysinternals/bb896653在尝试生成它之前杀死filename.exe".
check that "filename.exe" is not running, I guess you are using Microsoft Windows, in that case you can use either Task Manager or Process Explorer : http://technet.microsoft.com/en-us/sysinternals/bb896653 to kill "filename.exe" before trying to generate it.
这篇关于无法打开输出文件,权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!