CFile accessDenied
-
I have been trying to resolve this problem all morning. I'm running WinXP and have VC++6 SP5 with the latest PSDK installed, and I don't know what I'm doing wrong. I am trying to dump into a buffer a HTML file but keep getting this error:
CFile exception: accessDenied, File Unknown, OS error information = 5.
First-chance exception in WebServer.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.I have tried stepping through it and looking at msdn.microsoft.com (what a joke) for the error message and the steps to resolve it but can't find anything. Here is a code snippet and let me know if I am doing something wrong.
CFile SendFile;
if (!SendFile.Open("c:\\wwwroot\\index.html", CFile::readOnly|CFile::shareDenyWrite|CFile::typeBinary))
return -1;DataLeft=SendFile.GetLength(); SendFile.Read(SendData, (UINT)DataLeft);
I have tried using the CFile Open method and the overloaded constructor to open this file and read it, but to no avail. It opens fine, but when reading in the document I get the exception noted above. The error is thrown at the call to the Read method. Anyone know what's wrong? I am baffled and my brain is about to fry. This is part of a webserver I'm writing as a hobby project and one I'll post to the site when I can get bare minimums working :) (that is if anyone is interested) HomeNuke ---- "Nuke'd Your Home, Yet?" Run your own PostNuke based web server from home http://www.homenuke.com
-
I have been trying to resolve this problem all morning. I'm running WinXP and have VC++6 SP5 with the latest PSDK installed, and I don't know what I'm doing wrong. I am trying to dump into a buffer a HTML file but keep getting this error:
CFile exception: accessDenied, File Unknown, OS error information = 5.
First-chance exception in WebServer.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.I have tried stepping through it and looking at msdn.microsoft.com (what a joke) for the error message and the steps to resolve it but can't find anything. Here is a code snippet and let me know if I am doing something wrong.
CFile SendFile;
if (!SendFile.Open("c:\\wwwroot\\index.html", CFile::readOnly|CFile::shareDenyWrite|CFile::typeBinary))
return -1;DataLeft=SendFile.GetLength(); SendFile.Read(SendData, (UINT)DataLeft);
I have tried using the CFile Open method and the overloaded constructor to open this file and read it, but to no avail. It opens fine, but when reading in the document I get the exception noted above. The error is thrown at the call to the Read method. Anyone know what's wrong? I am baffled and my brain is about to fry. This is part of a webserver I'm writing as a hobby project and one I'll post to the site when I can get bare minimums working :) (that is if anyone is interested) HomeNuke ---- "Nuke'd Your Home, Yet?" Run your own PostNuke based web server from home http://www.homenuke.com
Get rid from
CFile::typeBinary
. You cannot use it withCFile
, only with derived classes Philip Patrick "Two beer or not two beer?" (Shakesbeer) Web-site: www.saintopatrick.com -
Get rid from
CFile::typeBinary
. You cannot use it withCFile
, only with derived classes Philip Patrick "Two beer or not two beer?" (Shakesbeer) Web-site: www.saintopatrick.comooops...hehe shows you how desperate I am. This is one variation of code I was trying just to see if that was the problem because the error message was unknown file. I have removed and have tried it without the CFile::typeBinary but still get the same error. Remember to remove 'I am stupid' code before submitting HomeNuke ---- "Nuke'd Your Home, Yet?" Run your own PostNuke based web server from home http://www.homenuke.com
-
ooops...hehe shows you how desperate I am. This is one variation of code I was trying just to see if that was the problem because the error message was unknown file. I have removed and have tried it without the CFile::typeBinary but still get the same error. Remember to remove 'I am stupid' code before submitting HomeNuke ---- "Nuke'd Your Home, Yet?" Run your own PostNuke based web server from home http://www.homenuke.com
Hmm, try to set
CFile::modeReadWrite
and remove the share thingy, also did you check this on other files? That are not in the IIS web server directory? Check the Windows permissions of this folder also, sometimes IIS won't let "strangers" to touch its files :) Philip Patrick "Two beer or not two beer?" (Shakesbeer) Web-site: www.saintopatrick.com -
Hmm, try to set
CFile::modeReadWrite
and remove the share thingy, also did you check this on other files? That are not in the IIS web server directory? Check the Windows permissions of this folder also, sometimes IIS won't let "strangers" to touch its files :) Philip Patrick "Two beer or not two beer?" (Shakesbeer) Web-site: www.saintopatrick.comOK this is weird...hard to explain but here is the new source code I used to get it to work, and thanks for your help, because I have tried your suggestions and you have responded really quickly. Also just to clarify things I just used wwwroot as a directory for web objects since this is a directory IIS and Apache use, I don't have either of them installed, I just created that directory. But, enough of the rambling :) Here is the new source code:
if (!SendFile.Open"c:\\wwwroot\\index.html",CFile::modeRead|CFile::shareDenyNone))
return -1;DataLeft=SendFile.GetLength(); SendFile.Read(SendData, (UINT)DataLeft); Start=0;
I change CFile::readOnly to CFile::modeRead...I'm looking up the docs now to figure out why this one works?!?! Maybe CF::readOnly is for an inherited class? But at least we where able to solve this. Thanks for your help PHILIP!!! HomeNuke ---- "Nuke'd Your Home, Yet?" Run your own PostNuke based web server from home http://www.homenuke.com
-
OK this is weird...hard to explain but here is the new source code I used to get it to work, and thanks for your help, because I have tried your suggestions and you have responded really quickly. Also just to clarify things I just used wwwroot as a directory for web objects since this is a directory IIS and Apache use, I don't have either of them installed, I just created that directory. But, enough of the rambling :) Here is the new source code:
if (!SendFile.Open"c:\\wwwroot\\index.html",CFile::modeRead|CFile::shareDenyNone))
return -1;DataLeft=SendFile.GetLength(); SendFile.Read(SendData, (UINT)DataLeft); Start=0;
I change CFile::readOnly to CFile::modeRead...I'm looking up the docs now to figure out why this one works?!?! Maybe CF::readOnly is for an inherited class? But at least we where able to solve this. Thanks for your help PHILIP!!! HomeNuke ---- "Nuke'd Your Home, Yet?" Run your own PostNuke based web server from home http://www.homenuke.com
My bad :) LOL, I didn't pay attention to this too, and this is funny :) Well, CFile::readOnly is used.... for attribute of the file! :) You know, like Hidden, ReadOnly, etc. :) And the value of it is same as.... CFile::modeWrite!! LMAO, so at the end it is trying to read from file opened on;y for writing. LMAO Philip Patrick "Two beer or not two beer?" (Shakesbeer) Web-site: www.saintopatrick.com