Search code examples
c#silverlightioelevated-privileges

SecurityException when calling System.IO.Path.GetTempPath()


I'm working on a silverlight elevated trust application. I made a call to

System.IO.Path.GetTempPath()

I am getting a Security Exception, message "File operation not permitted. Access to path '' is denied."

Application.Current.HasElevatedPermissions

Returns true

Any help would greatly be appreciated.


Solution

  • Edit: I think you can't do this stuff from the Silverlight sandbox. Try isolated storage instead.

    Old answer: From Path.GetTempPath:

    This method checks for the existence of environment variables in the following order and uses the first path found:

    1. The path specified by the TMP environment variable.

    2. The path specified by the TEMP environment variable.

    3. The path specified by the USERPROFILE environment variable.

    4. The Windows directory.

    Perhaps you can use System.Environment.GetFolderPath instead.