c++winapiwindowserror

ERROR_PATH_NOT_FOUND vs ERROR_FILE_NOT_FOUND, what is the difference?


I usually get ERROR_FILE_NOT_FOUND when I try to open a file that's not there, but now fopen() fails and GetLastError() returns ERROR_PATH_NOT_FOUND.

So what is the difference between ERROR_FILE_NOT_FOUND and ERROR_PATH_NOT_FOUND?


Solution

  • In WinError.h, ERROR_FILE_NOT_FOUND has the descriptive text "The system cannot find the file specified." and ERROR_PATH_NOT_FOUND has the descriptive text "The system cannot find the path specified."

    This doesn't particularly clarify matters.

    Usually, however, "file not found" refers to the case where the file itself cannot be found and "path not found" refers to the case where a component of the path (one of the directory names specified) cannot be found.