locked
Path.GetTempFileName Access to path is denied. RRS feed

  • Question

  • I am have a problem with  Path.GetTempFileName with running a Silverlight application. If I install my application to run Out-Of-browser it runs ok. It only fails when I run it locally i.e. In-Browser.

    The error is

    File operation not permitted. Access to path '' is denied.

    I cannot debug my application because of this issue. Can anyone suggest a work around?


    Bob Avallone

    Monday, October 7, 2013 9:02 PM

Answers

All replies

  • Hello,

    Path.GetTempFileName method creates a temporary file with a .TMP file extension. The temporary file is created within the user’s temporary folder, which is the path returned by the GetTempPath method. However, according to Path.GetTempPath introduces, this method checks for the existence of environment variables which is typically on the C:\. For security reasons, in-browser applications aren't allowed local access. so the root cause of this error may due to accessing the path. For that, I would like to suggest you use isolated storage instead.

    Here are some threads talking similar issue for your reference:

    http://stackoverflow.com/questions/19234806/path-gettempfilename-causes-access-to-path-is-denied-in-silverlight

    http://stackoverflow.com/questions/6931937/securityexception-when-calling-system-io-path-gettemppath

    Hope this helps, thanks.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Yanping Wang Wednesday, October 9, 2013 2:00 AM
    • Marked as answer by Yanping Wang Monday, October 14, 2013 11:49 AM
    Wednesday, October 9, 2013 1:59 AM
  • Hi Yanping,

    I appreciate your responding to me.

    I have noticed that another Silverlight application I wrote which is almost identical is not giving me this problem. That is Path.GetTempPath works ok. I am at a loss as to why one application works and the other one does not. The isolated storage idea didn't work for me because it does not persist.

    The bottom line is I am still looking for an answer.


    Bob Avallone

    Tuesday, January 7, 2014 8:49 PM