Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
打开资源管理器窗口后,C#exe文件被锁定,我得到;错误CS0016:无法写入输出文件";_C#_Csc - Fatal编程技术网

打开资源管理器窗口后,C#exe文件被锁定,我得到;错误CS0016:无法写入输出文件";

打开资源管理器窗口后,C#exe文件被锁定,我得到;错误CS0016:无法写入输出文件";,c#,csc,C#,Csc,如果我在目录中打开一个资源管理器窗口,即start.,那么一旦我这样做,我就无法编译它,甚至在关闭资源管理器窗口后,我也无法编译它或删除exe文件一段时间 C:\blah\ff>notepad.exe asdf.csc C:\blah\ff>type asdf.csc class a { public static void Main(string[] args){} } C:\blah\ff> C:\blah\ff>csc asdf.csc Microsoft (R

如果我在目录中打开一个资源管理器窗口,即
start.
,那么一旦我这样做,我就无法编译它,甚至在关闭资源管理器窗口后,我也无法编译它或删除exe文件一段时间

C:\blah\ff>notepad.exe asdf.csc

C:\blah\ff>type asdf.csc
class a {  public static void Main(string[] args){} }
C:\blah\ff>
C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240


C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240


C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240
^^在那里编译没有问题,现在看看我开始时会发生什么。

C:\blah\ff>start .

C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

error CS0016: Could not write to output file 'c:\blah\ff\asdf.exe' -- 'The process cannot access the file because it is being used by another process.
        '

C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

error CS0016: Could not write to output file 'c:\blah\ff\asdf.exe' -- 'The process cannot access the file because it is being used by another process.
        '

C:\blah\ff>
一段时间后,我可以编译,我可以删除exe文件

现在我将再次演示,这次显示删除exe文件的问题

看,我能够编译('因为我等了一会儿,我认为它“解决了”)

现在我来触发这个问题

C:\blah\ff>start .

C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

error CS0016: Could not write to output file 'c:\blah\ff\asdf.exe' -- 'The process cannot access the file because it is being used by another process.
        '
^^正如你看到的,它没有编译

C:\blah\ff>del asdf.exe

C:\blah\ff>dir
 Volume in drive C has no label.
 Volume Serial Number is B411-D580

 Directory of C:\blah\ff

16/10/2016  03:13 AM    <DIR>          .
16/10/2016  03:13 AM    <DIR>          ..
16/10/2016  03:10 AM                53 asdf.csc
16/10/2016  03:13 AM             3,584 asdf.exe
               2 File(s)          3,637 bytes
               2 Dir(s)   2,886,389,760 bytes free

因此,当我等待它让我删除它或让我编译一个同名的exe时,我使用
csc/out:asdf_u2;.exe asdf.csc
,这很好,但并不理想。

您可能还想检查哪个进程保持文件打开,但我打赌它将是explorer.exe。。。很可能您已经安装了一些wired/buggy插件,在浏览器窗口打开时锁定exe文件。。。检查最近安装的工具/病毒/抗病毒病毒,看看您是否可以发现它…您是否有任何浏览器扩展可能需要一段时间来处理它扫描的文件?甚至可以无限期地打开它?通过执行
start.
,系统将启动
的默认程序,该程序指向文件夹,即
explorer
。如果你从“开始/运行”菜单打开一个资源管理器窗口到文件夹并立即尝试编译,你会得到同样的行为吗?@AlexeiLevenkov你说得对,当资源管理器窗口打开时,我有东西锁定exe文件!我完全不知道那是什么is@JeffMercado当我转到“运行”对话框并从那里打开资源管理器窗口时,仍然会看到这种现象。这让我想起了一点,你不能从system32中删除可执行文件,如果你尝试的话,它们会重新出现。。对于不是EXE的文件,我没有这个问题!我记得有一个类似的问题,结果是目标目录位于dropbox子文件夹中…您可能还想检查哪个进程保持文件打开,但我打赌它将是explorer.exe。。。很可能您已经安装了一些wired/buggy插件,在浏览器窗口打开时锁定exe文件。。。检查最近安装的工具/病毒/抗病毒病毒,看看您是否可以发现它…您是否有任何浏览器扩展可能需要一段时间来处理它扫描的文件?甚至可以无限期地打开它?通过执行
start.
,系统将启动
的默认程序,该程序指向文件夹,即
explorer
。如果你从“开始/运行”菜单打开一个资源管理器窗口到文件夹并立即尝试编译,你会得到同样的行为吗?@AlexeiLevenkov你说得对,当资源管理器窗口打开时,我有东西锁定exe文件!我完全不知道那是什么is@JeffMercado当我转到“运行”对话框并从那里打开资源管理器窗口时,仍然会看到这种现象。这让我想起了一点,你不能从system32中删除可执行文件,如果你尝试的话,它们会重新出现。。对于不是EXE的文件,我没有这个问题!我记得有一个类似的问题,结果是目标目录位于dropbox子文件夹中。。。
C:\blah\ff>del asdf.exe

C:\blah\ff>dir
 Volume in drive C has no label.
 Volume Serial Number is B411-D580

 Directory of C:\blah\ff

16/10/2016  03:13 AM    <DIR>          .
16/10/2016  03:13 AM    <DIR>          ..
16/10/2016  03:10 AM                53 asdf.csc
16/10/2016  03:13 AM             3,584 asdf.exe
               2 File(s)          3,637 bytes
               2 Dir(s)   2,886,389,760 bytes free
C:\blah\ff>del asdf.exe
C:\blah\ff\asdf.exe
Access is denied.

C:\blah\ff>