File access issue after installing windows patch RRS feed

  • Question

  • Hi,

    We started having the error below:

    System.IO.IOException: The process cannot access the file because it is being used by another process.

    It started when we installed the windows patches listed in the attached image.

    The IOException is thrown randomly, with 30000 files processed, around 5 files will encounter this exception.

    The temporary solution we did was to change the call to File.Move() function to a new function that will retry if there's an IOException.
    The retry will try 5 times each time waiting for 1 second - Thread.Sleep(1000).
    This solution worked but we need a permanent fix for this issue as we are encountering this issue in other parts of the codes too.

    Source code:

    private void processFiles(string incomingFolder, string processingFolder)
        FileInfo[] files = GetFiles(incomingFolder);
        foreach(var file in files)
            File.Move(file.FullName, processingFolder);

        FileInfo[] files2 = GetFiles(processingFolder);
        foreach(var file in files2)

    private void sampleProcessingMethod(string filePath)
        // Get new file name - just appends a time stamp to the file name
        string renameTo = GetNewFileName(filePath);

        // rename the file on the same folder
        File.Move(filePath, renameTo);  // <--- This is where the IOException is thrown

    Wednesday, April 11, 2018 8:39 AM

All replies

  • This is an end user forum, so you don't reach Microsoft by telling this here. 

    Use in Visual Studio Help -> Send Feedback


    Wednesday, April 11, 2018 8:57 AM
  • Hi Arvinb,

    Thank you for posting here.

    According to your error message, please check the five files whether it used or not when you running the code to access.

    If the file does not be used, it is not the error from code. Please ask in the link below according to the version of your windows.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, April 12, 2018 7:40 AM