none
DirectoryInfo.GetDirectories hangs and locks Visual Studio output file RRS feed

  • Question

  • When I run the following program from within Visual Studio 2015 it hangs and the only way I can exit is to close the Console window with the mouse.

    using System.IO;
    
    namespace Test
    {
        class Program
        {
            static void Main(string[] args)
            {
                DirectoryInfo[] dirs = new DirectoryInfo(@"D:\").GetDirectories();
            }
        }
    }

    Afterwards I am unable to recompile the project as it gives the following errors:

    Error Could not copy "obj\Debug\Test.exe" to "bin\Debug\Test.exe". Exceeded retry count of 10. Failed. Test
    Error Unable to copy file "obj\Debug\Test.exe" to "bin\Debug\Test.exe". The process cannot access the file 'bin\Debug\Test.exe' because it is being used by another process. Test

    Any ideas why?


    Sunday, November 15, 2015 10:37 AM

Answers

All replies

  • Hi mahbouni,

    I have encountered the error messages before. Mostly it occurred when the debug process was stopped somewhere in an exception.Please try to clean+build has no effect, closing VS, deleting 'bin' and 'obj' folders an opening VS again has till now always resolved the issue.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Kristin Xie Monday, November 16, 2015 2:34 AM
    Monday, November 16, 2015 2:33 AM
  • Hi Kristin,

    Thank you for your response. I did already clean+build but I still got the same error. I did also try closing VS but that didn't work either. I was unable to delete the bin folder, as the output exe file was locked. The only thing that worked for me so far was restarting Windows 10.

    Monday, November 16, 2015 8:51 AM
  • I found the problem. After uninstalling Avast antivirus the problem goes away
    Tuesday, November 17, 2015 9:02 AM
  • Hi mahbouni,

    Glad to hear you have work it out by yourself, and thanks for sharing here.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, November 17, 2015 9:03 AM