How to get location of "Temporary ASP.NET Files" folder

  • Thread starter Thread starter Ajay Choudhary
  • Start date Start date
A

Ajay Choudhary

Hi,

Is there a way to find the following path through C# code -
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files"

The only solution I have is to get the registry value of
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\
and append .NET version and "Temporary ASP.NET Files".

Any other idea is greatly appreciated.

Thanks,
Ajay
 
This is how I do it, there may be a better way, if you find one, I'd love to
know:

/// <summary>
/// Returns the path to aspnet script files
/// </summary>
/// <param name="pContext"></param>
/// <returns></returns>
public static string GetScriptLocation(System.Web.HttpContext pContext)
{
string strClientScriptsLocation = "";
string strVersion = "";
object pObject = pContext.GetConfig("system.web/webControls");
if (pObject != null)
{
Hashtable pHash = (Hashtable)pObject;
strClientScriptsLocation = pHash["clientScriptsLocation"].ToString();
}

strVersion = System.Environment.Version.ToString(3).Replace(".","_");

string strLocation = String.Format(strClientScriptsLocation, "system_web",
strVersion);
return strLocation;
}
 
I found the answer -

Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(),/*MSG0*/"Temporary
ASP.NET Files")



Jeremy Chapman said:
This is how I do it, there may be a better way, if you find one, I'd love
to know:

/// <summary>
/// Returns the path to aspnet script files
/// </summary>
/// <param name="pContext"></param>
/// <returns></returns>
public static string GetScriptLocation(System.Web.HttpContext pContext)
{
string strClientScriptsLocation = "";
string strVersion = "";
object pObject = pContext.GetConfig("system.web/webControls");
if (pObject != null)
{
Hashtable pHash = (Hashtable)pObject;
strClientScriptsLocation = pHash["clientScriptsLocation"].ToString();
}

strVersion = System.Environment.Version.ToString(3).Replace(".","_");

string strLocation = String.Format(strClientScriptsLocation, "system_web",
strVersion);
return strLocation;
}

Ajay Choudhary said:
Hi,

Is there a way to find the following path through C# code -
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files"

The only solution I have is to get the registry value of
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\
and append .NET version and "Temporary ASP.NET Files".

Any other idea is greatly appreciated.

Thanks,
Ajay
 
Back
Top