无法复制文件 - 访问路径被拒绝
我正在使用 Visual Studio 2005。首先从版本控制中获取代码后, c#.net 应用程序正确运行。但是,进行一些修改后,当我构建时,出现以下错误:
错误 383 无法将文件“..\root\leaf\Bin\Debug\test.Resources.xml”复制到 “Bin\Debug\test.Resources.xml”。访问路径“Bin\Debug\test.Resources.xml”是 否认。 li.roll模型
有谁知道为什么会出现这个问题?
编辑 我可以看到我的整个项目源代码文件夹是只读的,并且我无法删除只读属性。
首先,谁能告诉我如何删除该文件夹的只读属性?我尝试删除它,但只读属性仍然存在。我也从版本控制方面进行了尝试,但这也不起作用。
I am using Visual Studio 2005. After taking code from version control first,
the c#.net application runs correctly. But, after doing some modifications, when I build I am getting the following error:
Error 383 Unable to copy file "..\root\leaf\Bin\Debug\test.Resources.xml" to
"Bin\Debug\test.Resources.xml". Access to the path 'Bin\Debug\test.Resources.xml' is
denied. li.rollmodel
Does anybody know why this issue is occurring?
Edit I can see that my entire project source code folder is Read-only, and I am not able to remove the read-only property.
First, can anybody tell me how to remove the Read-only property for this folder? I have tried removing it but the read-only property persists. I tried from the version-control side also and that did not work, either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(30)
确保在路径名后附加文件名 (path\fileName.extension)。我花了一个多小时没有注意到这一点。
Make sure you append the file name after the path name (path\fileName.extension). I spent more than one hour without note this.
我通过从 bin 文件夹中删除有争议的文件并重建项目解决了这个问题。
I solved this problem by deleting the contentious files from bin folder and rebuilding the project.
只需确保该文件夹不是只读并重建解决方案
Just make sure that the folder is NOT Read-Only and rebuild the solution
我解决了这个问题:
关闭 Visual Studio,再次打开它并加载解决方案,重建您的解决方案。我在使用 TFS 和 VIsual Studio 2010 时出现问题。
I solved this problem:
Close Visual Studio, open it again and load the solution, Rebuild your solution. My problem occurred using TFS and VIsual Studio 2010.
终止进程
VBCSCompiler.exe
并重建。Kill process
VBCSCompiler.exe
and rebuild.以管理员身份运行 Visual Studio。或者您可以在输出文件夹上向“用户”添加写入权限
Run your Visual Studio as Administrator. Or you can add write permission to "Users" on the output folder
我也遇到了这个问题。
首先检查您是否已将 bin 和 obj 文件夹映射到源代码管理程序。
这可能会将您的文件从二进制文件夹变成只读存档,这使得 Visual Studio 在编译代码时无法覆盖它们。
从这些文件夹中删除映射,检查更改并重试。
我使用 TFS(团队基础服务器)和 Visual Studio 2010 时出现问题。
希望这对某人有帮助。
I stepped into this problem too.
First go and check if you have mapped your bin and obj folder to the Source Control program.
This may be turning your files from binaries folders into read only archives, which make impossible to visual studio to overwrite them when it compiles the code.
Go and remove the mapping from these folders, check the changes and try again.
My problem occurred using TFS(Team foundation server) and Visual Studio 2010.
Hope this helps someone.
就我而言,是防病毒软件阻止了该文件。
In my case it was the antivirus which blocked the file.
就我而言,avast 防病毒软件隔离了需要从 avast 应用程序复制的 [app-name].exe 文件,因此我必须转到“保护”>“隔离,单击文件旁边的菜单按钮,然后单击“恢复并添加例外”,如下所示
In my case, avast anti-virus quarantined the [app-name].exe file that needs to be copied so from the avast app, I had to go to protection > Quarantine, click the menu button beside the file and click 'restore and add exception' as shown below
我使用 Visual Studio 2013。我遇到过这个问题 2 次:
第一次,我在没有管理员权限的情况下运行 Visual Studio。因此,我关闭了 VS 并使用“以管理员身份运行”选项启动它。这解决了我的问题。
第二次,我多次重新启动 VS,每次都确保以管理员身份运行它。另外,我多次重建解决方案。但是,尽管如此,我还是遇到了错误。
之后,我从目标位置删除了相关文件(该文件已经存在,可能来自它尝试复制到的位置的先前版本)并重建解决方案强>。之后,错误消失,一切顺利!
I use Visual Studio 2013. I faced this problem 2 times:
On first occasion, I was running Visual Studio without Administrator rights. So, I closed VS and started it using 'Run as administrator' option. This solved my problem.
On second occasion, I restarted VS many times, every time making sure that I am running it as an administrator. Also, I rebuilt solution many times. But, in spite of that I was getting error.
After that, I removed the concerned file from the target location (the file was already present may be from the previous build at the location where it tries to copy to) and rebuilt the solution. After that, error went away and everything ran smoothly!
首先转到文件所在位置。然后右键单击该文件的文件夹->属性-> 未选中只读选项并应用于文件及其子文件夹。
它解决了我的问题。
快乐编码!
First go to location of the file. Then right click on the folder of the file -> Properties -> Unchecked Read Only Option and apply to files and its sub folders.
It resolved my issue.
Happy Coding!
这种情况在 Visual Studio 2017 中再次出现,在本例中,原因是 Application Insights 进程 ServiceHub.DataWarehouseHost.exe。
线程 警告中讨论了一种解决方法MSB3026:无法将“obj\Debug\netcoreapp1.1\src.pdb”复制到“bin\Debug\netcoreapp1.1\src.pdb”,就是在项目中添加一个预构建事件,用于在每次构建项目时杀死进程。引用该链接:
This has reared it's head again in Visual Studio 2017, in this case the cause is the Application Insights process ServiceHub.DataWarehouseHost.exe.
There is a workaround discussed in the thread warning MSB3026: Could not copy "obj\Debug\netcoreapp1.1\src.pdb" to "bin\Debug\netcoreapp1.1\src.pdb", which is to add a pre-build event to the project to kill the process every time the project is built. Quoting from that link:
看看您通过手动复制解决问题的回复,我想说您正在处理的代码是由其他用户(也具有管理员权限)编写的,因此它被锁定给您。通过执行复制——?粘贴后,您就制作了自己的源副本,并具有所需的所有访问权限。唯一需要注意的是,在这种情况下,如果其他开发人员需要处理您的副本,他/她将陷入与您之前遇到的相同问题。
Looking at your response that you resolved your problem by manual copying, I would say that the code you were working on was made by some other user (with administrator privileges too) so it was locked to you. By performing copy --? paste, you made your OWN copy of the source with all access you required. The only thing to notice is that, in this case if this other developer will need to work on your copy, he/she will jump in pretty same problem you got before.
老帖子,但是这个僵尸正在攻击 VS 2017(我还没有深入研究为什么它只是“一些”项目)。在这种情况下,这不是用户权限,而是 IIS Express 进程仍在使用这些文件。
您将在任务托盘中看到该图标
重建
,而不会出现此恼人的“权限被拒绝”消息。这也是为什么“重新启动 Visual Studio”将“修复”该问题。这样做会停止 IIS Express。
呃……
Old post, but this zombie is hitting VS 2017 (I haven't dug into why it's just "some" projects). In this case, it's not user permissions, rather IIS Express process is still using the files.
You'll see the icon in your task tray
rebuild
without this annoying "permission denied" message.This is also why "restarting Visual Studio" will "fix" the issue. Doing so, stops IIS Express.
Hth...
我重新添加了所有非 .NET 依赖项/引用,它成功了。
I re-added all of my non-.NET dependencies / references and it did the trick.
我自己解决了这个问题。问题是我在另一个地方打开了解决方案。关闭后就可以用了
I resolved this issue myself. The problem was I had the solution opened in another place. After closing it it works
遇到了同样的问题,但每次都重新启动 Visual Studio 对我来说是不可能的,因为该问题有时会经常发生。
我通过安装Unlocker(< em>尝试在安装时安装任何工具栏,所以不要忘记取消选中此选项),此应用程序让我可以快速访问重命名/删除锁定的工具栏“.xml”-文件。我知道这也只是一种解决方法,但对我来说,这是解决此问题的最快解决方案。
Had the same problem, but restarting Visual Studio every time was no option for me, as the issue occurs sometimes very often.
I handled it by installing Unlocker (tries to install any toolbar at installation, so don't forget to uncheck this), this application gives me fast access to rename/delete a locked ".xml"-File. I know that this only a workaround too, but for me it was the fastest solution to solve this problem.
我看到的大多数答案都是客观地探索环境中可能存在的问题,这对于 99% 遇到此问题的人来说可能是正确的(无法将文件从...复制到...访问被拒绝)。
我想我应该为那 1% 由于其他原因遇到这个问题的人分享我的经验。
我编写了一个批处理文件重命名程序,用于处理数万个文件,我的防病毒软件将其解释为木马并自动隔离它。由于此路径位于我的 AntiVirus 黑名单中,Visual Studio 永远无法将 *.exe 复制到 bin 文件夹中,因此导致无法复制 .exe。
我的解决方案是将此路径列入白名单,问题已解决。
干杯。
Most of the answers I have seen are objectively exploring possible issues with the environment, which is probably correct for 99% of the people running into this issue (unable to copy file from ... to ... access is denied).
I thought I should share my experience for the 1% who ran into this problem due to misc reasons.
I wrote a batch file renaming program that i use to act on tens of thousands of files, and my AntiVirus interpreted it as trojan and auto quarantined it. Having this path sit in my AntiVirus' blacklist, visual studio can never copy the *.exe into the bin folder, hence resulting unable to copy .exe.
My resolution is to whitelist this path and the issue is resolve.
Cheers.
当我向解决方案添加新的安装项目,然后直接将文件从主应用程序项目的 /bin/release 文件夹添加到安装项目的应用程序文件文件夹时,我创建了此问题。安装项目的源代码控制始终阻止我完成主应用程序项目的构建。
解决方案:在任何项目之外创建一个单独的转储文件夹,其中将包含要包含在安装中的所有文件,并从那里添加它们。这很痛苦,因为现在我必须记住复制每个新安装包的所有文件。我可能会看看是否可以通过构建后操作(我们的自动化构建)做一些事情,以使过程更加顺利。
I created this problem when I added a new setup project to the solution, and then added files directly from the /bin/release folder of the main application project to the application files folder of the setup project. The source control of the setup project was consistently blocking me from completing a build of the main application project.
Solution: create a separate dump folder outside of any of the projects that will contain all the files to be included in the install, and add them from there. It's a pain because now I have to remember to copy all the files for each new install package. I might see if I can do something with post-build actions our an automated build to make the process smoother.
如果将任何文件复制到解决方案,请确保这些文件不处于只读模式。右键单击文件并取消选中属性选项解决了我的问题。
If you copy any files across to a solution, make sure the files are not in Read Only mode. Right click on file and uncheck the attribute option solved my problem.
我遇到了同样的错误,但我正在使用 Perforce 版本控制。这是我修复它的方法。
I had the same error but I am using Perforce version control. Here's how I fixed it.
我也有同样的问题。我收到与无法复制相关的错误消息,因为访问路径被拒绝。就我而言,所有 dll 和 xml 文件等都位于 D:\TFS\Example\Bin\Debug 文件夹中。
我右键单击 Bin 文件夹,然后单击“属性”,看到“属性”下选中了“只读”复选框。
我取消选中“只读”复选框,然后单击“应用”,然后在显示的新弹出窗口中单击“确定”。
我回到 Visual Studio 并构建我的解决方案,该解决方案给了我错误消息。
瞧.. 这次它构建成功,没有错误。
我不知道这是否完美,但我这样做是为了解决我的问题。
I also had same problem. I got error messages that related to cannot copy since access to path denied. In my case all my dll's and xml files and so on are place at D:\TFS\Example\Bin\Debug folder.
I right clicked on Bin folder and clicked Properties and saw that Read-only check box is checked under Attributes.
I un-checked Read only check box and cliked Apply and clicked OK on the new popup that is shown.
I went back to Visual Studio and build my solution which was giving me error messages.
Voilaa.. This time it build successfully without errors.
I donot know whether this is perfect but I did this to solve my issue.
检查任务管理器并确保没有 devenv.exe 进程挂起。终止失控进程并重试。
Check Task Manager and make sure you don't have a devenv.exe process hanging. Kill the runaway process and try again.
转到文件路径,然后取消选中该文件的只读复选框。
Go to file's path then un-check read only checkbox of this file.
我知道这是一个旧线程,但对于那些寻找答案的人,就像几分钟前的我一样,我建议首先尝试重新启动计算机。仅此一点就为我解决了。之前甚至无法手动复制到文件夹。
I know its an old thread but for those looking for answers, like me a few minutes ago, I recommend trying to restart your computer first. That alone fixed for me. Before could not even manualy copy to the folder.
只需右键单击您的 MVC 项目,然后单击清理选项。我遇到了类似的问题,在重建之前清理项目为我解决了这个问题。
Just right click on your MVC project and click on the clean option. I had a similar problem and cleaning the project before rebuilding resolved it for me.
我也有同样的问题。我通过取消选中根文件夹的只读属性来修复它。
I had also the same problem. I fixed it by unchecking the Read-only properties of root folder.
我也有这个问题。以下是解决从项目中排除
bin
文件夹的方法这个过程对我有用。
I also had this issue. Here's how is resolved this
bin
folder from project.This process is works for me.
我能够通过从目标网站的 bin 文件夹中删除正在抱怨的目标文件(在您的示例中为“Bin\Debug\test.Resources.xml”)并重新构建它来解决该问题。这为我修复了它。
I was able to resolve the problem by removing the target file which is complaining(in your example "Bin\Debug\test.Resources.xml") from bin folder of target web site and re build it.That fixed it for me.
我在这里尝试了所有方法,但以某种方式删除项目中的所有 bin 和 obj 文件夹却不起作用。从其他进程释放文件夹没有任何作用。重新启动什么也没做。通过在主文件夹上取消选中每个文件来删除只读文件并没有帮助。
每个依赖性最终都会将自己添加到问题中。直接在依赖项文件夹中构建是有效的,所以我很困惑。我本来打算重复这个问题,但我发现了一些有用的东西。
你知道什么有效吗?
dotnet 干净
I tried everything here, somehow deleting all the bin and obj folders in my project didn't work. Releasing the folders from other processes did nothing. Restarting did nothing. Removing read only from every file by unchecking it on the main folder didn't help.
Every dependency ended up adding themselves to the problem. Building directly in the dependencies' folder worked so I was confused. I was going to duplicate this question but I found something that worked.
You know what worked?
dotnet clean