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

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
 
J

Jeremy Chapman

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;
}
 
A

Ajay Choudhary

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top