Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CFile accessDenied

CFile accessDenied

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++htmldatabasecom
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HomeNuke
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • H HomeNuke

      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

      P Offline
      P Offline
      Philip Patrick
      wrote on last edited by
      #2

      Get rid from CFile::typeBinary. You cannot use it with CFile, only with derived classes Philip Patrick "Two beer or not two beer?" (Shakesbeer) Web-site: www.saintopatrick.com

      H 1 Reply Last reply
      0
      • P Philip Patrick

        Get rid from CFile::typeBinary. You cannot use it with CFile, only with derived classes Philip Patrick "Two beer or not two beer?" (Shakesbeer) Web-site: www.saintopatrick.com

        H Offline
        H Offline
        HomeNuke
        wrote on last edited by
        #3

        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

        P 1 Reply Last reply
        0
        • H HomeNuke

          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

          P Offline
          P Offline
          Philip Patrick
          wrote on last edited by
          #4

          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

          H 1 Reply Last reply
          0
          • P Philip Patrick

            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

            H Offline
            H Offline
            HomeNuke
            wrote on last edited by
            #5

            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

            P 1 Reply Last reply
            0
            • H HomeNuke

              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

              P Offline
              P Offline
              Philip Patrick
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups