FIX: "_stat" or "_wstat" function fails together with ENOENT error when a directory symbolic link path is passed to it in a Visual C++ 2010 application

Applies to: Visual C++ 2010 Express

This hotfix applies to Microsoft Visual C++ 2010 Service Pack 1 (SP1) Redistributable Package.


Consider the following scenario:
  • You have a folder named "folder1" on drive D. For example, you have the following folder: d:\folder1.
  • You run the mklink command to create a directory symbolic link to the folder. For example, you run the following command to create a directory symbolic link folder on drive C:
    mklink /d c:\linkfolder d:\folder1  
  • You run a Microsoft Visual C++ 2010 application.
  • The application calls the _stat or _wstat function, and then it passes the path of the directory symbolic link "c:\linkfolder" to the path parameter.
In this scenario, the called function does not work, and it returns an ERROR_FILE_NOT_FOUND error.

Note The returned value of the _stat or _wstat function is -1. The error code is "2," which stands for "ENOENT: No such file or directory."


Hotfix information

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem.

If the hotfix is available for download, there is a "Hotfix Download Available" section at the top of this Knowledge Base article. If this section does not appear, submit a request to Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft website: Note The "Hotfix Download Available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.


To apply this hotfix, you must have Microsoft Visual C++ 2010 SP1 Redistributable Package installed.

Restart requirement

You may have to restart the computer after you install the hotfix if the affected files are not being used at the time of installation. We recommend that you close all Visual C++ 2010-related components before you install the hotfix.


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.