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

2024-04-23

我使用 C# 语言使用 Windows 窗体应用程序,我有很多窗体,当我想从一个窗体遍历到另一个窗体时,我使用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"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

错误“无法复制文件,因为它正在被另一个进程使用 的相关文章

随机推荐