Menu

Access to the path 'Cache' is denied

Help
Anonymous
2010-10-18
2013-12-19
  • Anonymous

    Anonymous - 2010-10-18

    Hi,

    I'm just trying out the dotnetwikibot dll in a vb.net web project using vs2010 and I keep getting "Access to the path 'Cache' is denied" on line1 in page_load:
    Dim enWiki As New DotNetWikiBot.Site("http://en.wikipedia.org", "user", "pass")

    I'm running on local machine. I have tried to create cache directory in project home and in dll home to no avail.

    Thanks/Max

    System.UnauthorizedAccessException was unhandled by user code
      Message=Access to the path 'Cache' is denied.
      Source=mscorlib
      StackTrace:
           at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
           at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj)
           at System.IO.Directory.CreateDirectory(String path)
           at DotNetWikiBot.Site.GetPaths()
           at DotNetWikiBot.Site.Initialize()
           at DotNetWikiBot.Site..ctor(String site, String userName, String userPass, String userDomain)
           at DotNetWikiBot.Site..ctor(String site, String userName, String userPass)
           at BilVardet.TestWiki.Page_Load(Object sender, EventArgs e) in C:\Users\Max\Documents\My Dropbox\Visual Studio Projects\Projects\BilVardet\BilVardet\TestWiki.aspx.vb:line 11
           at System.Web.UI.Control.OnLoad(EventArgs e)
           at System.Web.UI.Control.LoadRecursive()
           at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      InnerException:

     
  • Anonymous

    Anonymous - 2010-10-20

    Also tried uploading to server (win2008/iis7) with same result. I'm using net 4. any ideas?

     
  • CodeDriller

    CodeDriller - 2010-10-20

    There is a special tool to analyze problems with assembly permissions (http://msdn.microsoft.com/en-us/library/tx1dts55.aspx). Try it. Probably some permission is missing at assembly level, particularly file system IO permission.

    Here is the list of permissions that I've been using for testing in different environments:
     
     
     
     
     
     
     
     
     

    If that doesn't help, I would advise to check permissions for "Cache" subdirectory of your DotNetWikiBot directory. There must be "Security" tab in the properties of that folder. Try experimenting with the permissions, try adding full permissions for everyone and particularly for services. If that subdirectory does not exist, try creating it manually and then experimenting with the permissions.

    Please, let me know if it helps.

     
  • Anonymous

    Anonymous - 2013-01-22

    2+ years old…but thought I'd add something I found.   I created a program which used DotNetWikiBot.  I set it up to be a single application instance and started it via one of the multimedia hotkeys on my keyboard, configured via the Microsoft Mouse and Keyboard center. 

    I was getting the same issue about the access to path cache is denied.   What I found is that it was trying to create the cache directory in c:\windows\syswow64, which as a mere end user I did not have access to.  If I started the program directly from explorer in it's "home" then all worked well. 

    Looking at the source, the code just tries to open "cache\….." assuming that whatever the current directory is should be where that cache should be.    I haven't done this yet, but my solution will be to to prepend something like %APPDATA% or %TEMP% to that location so that the cache storage is relative to the user account and not where the program runs from.

     
  • CodeDriller

    CodeDriller - 2013-01-22

    That's a good idea!

     
  • CharlieD

    CharlieD - 2013-12-19

    Thanks Anonyous helper! Solved my problem.

    In my case I just changed the code to force it to always create the cache folder in the same place that i had write access to.

    // Find path to index.php
    stringng cacheFile = serverPath + "/Cache" + Path.DirectorySeparatorChar +
    HttpUtility.UrlEncode(address.Replace("://", ".").Replace("/", ".")) + ".xml";
    if (!Directory.Exists("Cache"))
    Directory.CreateDirectory(serverPath + "/Cache");

    With serverpath being the root directory of my website.

    Perfect!

     

Log in to post a comment.