title: Why would fopen fail to open a file that exists?
body: <p>I'm on Windows XP using Visual Studio 6 (yes I know it's old) building/maintaining a C++ DLL. I'm encountered a problem with fopen failing to open an existing file, it always returns NULL. </p>
  
  <p>I've tried:</p>
  
  <ul>
  <li>Checking errno and _doserrno by setting both to zero and then checking them again, both remain zero, and thus GetLastError() reports no errors. I know fopen isn't required to set errno when it encounters an error according to a C standard. </li>
  <li>Hardcoding the file path, which are not relative. </li>
  <li>Tried on another developers machine which the same result.</li>
  </ul>
  
  <p>The really strange thing is CreateFile works and the file can be read with ReadFile. We believe this works in a release build, however we are also seeing some very odd behaviour in other areas of the application and we're not sure if this is related.</p>
  
  <p>The code is below, I don't see anything odd it looks quite standard to me. The source file hasn't changed for just under half a year.</p>
  
  <pre><code>HRESULT CDataHandler::LoadFile( CStdString szFilePath )
  {
      //Code
      FILE* pFile;
      if ( NULL == ( pFile = fopen( szFilePath.c_str(), "rb") ) )
      {
          return S_FALSE;
      }
      //More code
  }
  </code></pre>