1
How to change default path of temporary files
Question asked by Ruben Sanchez - 2/14/2022 at 7:15 AM
Answered
Hi, I'm wondering if is possible to change the default path of temporary files, currently my default path is c:\windows\temp, but for storage reasons I need to change it, I'm working with C#, please if someone has done it, could you please helpme ?
RubenS

1 Reply

Reply to Thread
0
Cem Alacayir Replied
Employee Post Marked As Answer
Hi,
You can change it via GleamTechConfiguration.TemporaryFolder property. You should set it before calling other library methods, i.e. in application startup. Note that few files like DLLs may be stored in the initial location even if you change it, those are required for library loading but should not take much space (the size does not overgrow)

Note that there is also DocumentUltimateWebConfiguration.CacheLocation property which controls only the cache location for DocumentViewer. GleamTechConfiguration.TemporaryFolder property is for all temporary files created globally by GleamTech libraries.

GleamTechConfiguration.TemporaryFolder:
Gets or sets a value that specifies the temporary folder used as default by GleamTech components. The default value is "[System Temporary Folder]\GleamTech". Value can be a virtual or physical path.  
[System Temporary Folder] can be different for different environments:

  • - For "ASP.NET Classic":
    -- "%WINDIR%\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\APPNAME\xxxxxxxx"
    -- "%WINDIR%\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\APPNAME\xxxxxxxx" (if 32-bit AppPool)
    -- "%LOCALAPPDATA%\Temp\Temporary ASP.NET Files\vs\xxxxxxxx" (when debugging in Visual Studio)

  • - For "ASP.NET Core" the path set in "ASPNETCORE_TEMP" environment variable or result of Path.GetTempPath which depends on "TMP", "TEMP" and "USERPROFILE" environment variables:
    -- "%WINDIR%\Temp"
    -- "%LOCALAPPDATA%\Temp" (if "Load User Profile" is enabled for AppPool in IIS)

  • - For Azure WebApp Service:
    -- "D:\home" (%HOME% environment variable)

  • - For Console or other non-web apps, result of Path.GetTempPath which depends on "TMP", "TEMP" and "USERPROFILE" environment variables:
    -- "%LOCALAPPDATA%\Temp"
    -- "%WINDIR%\Temp"

For an ASP.NET Core project

Set your license key in appsettings.json file:

Json
{
  "GleamTech:TemporaryPath": "YOUR_PATH_HERE"
}

Alternatively you can set your license key in code, in Configure method of your Startup.cs after app.UseGleamTech call:

C#
app.UseGleamTech();

GleamTechConfiguration.Current.TemporaryFolder = "YOUR_PATH_HERE";


For an ASP.NET Classic (MVC or WebForms) project

Set your license key in <appSettings> tag of your Web.config:

XML
<appSettings>
  <add key="GleamTech:TemporaryPath" value="YOUR_PATH_HERE" />
</appSettings>

Alternatively you can set your license key in code, in Application_Start method of your Global.asax.cs:

protected void Application_Start(object sender, EventArgs e)
{
    GleamTechConfiguration.Current.TemporaryFolder = "YOUR_PATH_HERE";
}


For other project types

Set your license key in a static (Shared in VB) method, e.g. in Main method for a Console project:

static void Main(string[] args)
{
    GleamTechConfiguration.Current.TemporaryFolder = "YOUR_PATH_HERE";
}

Reply to Thread