I'm getting a "file not found" error (0x2) returned from the Platform
SDK function CreateHardLink(lpFileName, lpExistingFileName, NULL) that
is being called from within an IIS filter. The function is actually
called using two CStrings that are assigned from charvariables:
CreateHardLink(CString, CString, NULL);
I am logging activity from the filter into a text file. The log entry
with the error shows a valid source file -- when I cut/paste from the
log into the Windows Explorer's address bar, the file is accessed just
fine, so the file definitely exists. The problem may be with certain
"special characters" in the file name, though some of the file names it
is failing on seem "normal". Here are some of the files I'm getting
the "file not found" with (path not shown):
Note that the '? (ANSI 228) in "Gewhs.zip" and the '? (ANSI 198)
in "Auto?sit" are both ANSI characters, not unicode. The other two
file names contain normal characters (the underscores are ANSI 095).
The directory exists where the link is being created.
The existing file and the link being created are both on the same
locally mounted hard-drive.
I wrote a C++ console app that takes two arguments from the command
line: the Link File (including path) and the Existing File (including
path). It executes CreateHardLink() using those strings passed in.
When executed on the same server that the IIS filter is running on
using the same paths/files mentioned above, it creates the hard-link
with no errors! It's basically the same code that is in the IIS
filter, except the CString arguments that are passed to
CreateHardLink() are assigned from the argv values passed in from the
CreateHardLink(csHardLinkFileName, csExistingFileName, NULL);
Essentially this is the same code as in the IIS filter, but this works
and the filter does not!
The IIS filter is running on MS Windows 2000 Server SP4
/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D
"_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /D _WIN32_WINNT=0x500
/Fp"Release/ISAPIFilter.pch" /Yu"stdafx.h" /Fo"Release/"
/Fd"Release/" /FD /c
Very strange! Any answers?