title: How to set the Temp path ie. the value returned by Path.GetTempPath()?
body: <p>I was trying to run a ASP.net 2.0 site under impersonation and something seems to have gone wrong. I undid my changes in the ASP.Net IIS Configuration applet.</p>
  
  <p>However now I am stuck with this error</p>
  
  <pre><code>System.UnauthorizedAccessException: Access to the temp directory is denied.  Identity 'MACHINE\ASPNET' under which XmlSerializer is running does not have sufficient permission to access the temp directory.  CodeDom will use the user account the process is using to do the compilation, so if the user doesnt have access to system temp directory, you will not be able to compile.  Use Path.GetTempPath() API to find out the temp directory location.
     at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
     at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
     at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
     at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Evidence evidence)
     at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
  </code></pre>
  
  <p>So I tried changing the temp path - however MSDN doesn't state as to how it derives this value. I tried setting the TEMP and TMP environment variables but that didnt affect it either. It still points to C:\Tmp folder which is mapped as a drive due to some admin policy apparently from a Mordac like character around these parts.</p>
  
  <p>Update: It seems that the change has now belatedly taken effect. Path.GetTempPath now shows the value i set to those 2 environment variables.</p>