gpt4 book ai didi

c# - 错误“无法复制文件,因为它正在被另一个进程使用

转载 作者:太空狗 更新时间:2023-10-29 19:50:06 25 4
gpt4 key购买 nike

我使用C#语言的windowsform应用程序,我有很多表单,当我想从一个表单遍历到另一个表单时,我使用this.Hide();

当我使用这个方法时,我收到显示的错误,

我知道解决方案是使用 Windows 任务管理器结束进程,但问题是有什么方法可以在不导致此错误的情况下使用表单之间的移动?

 Error  9   Unable to copy file "obj\x86\Debug\WindowsFormsApplication1.exe" to "bin\Debug\WindowsFormsApplication1.exe". The process cannot access the file 'bin\Debug\WindowsFormsApplication1.exe' because it is being used by another process.  C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets  2868

最佳答案

简单的解决方案是在项目属性中添加一些代码..

只需转到“项目”选项卡并选择项目属性。从那里选择构建事件选项卡。并在预构建事件命令行中添加以下代码..

   if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

关于c# - 错误“无法复制文件,因为它正在被另一个进程使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18321422/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com