Set Temp PDF File Path

C# + VB.Net: Set Temp PDF File Path Set Temp PDF File Path
// Install IronPdf with Nuget:  PM> Install-Package IronPdf
using IronPdf;

// Set Application scope Temp Path
var MyTempPath = @"C:\Safe\Location\";
Environment.SetEnvironmentVariable("TEMP", MyTempPath);
Environment.SetEnvironmentVariable("TMP",  MyTempPath);

// Set IronPDF Temp Path
IronPdf.Installation.TempFolderPath = Path.Combine(MyTempPath,"IronPdfTemp");

// Your PDF Generation and editing code here
var Renderer = new IronPdf.HtmlToPdf();
var doc =  Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
doc.SaveAs("example.pdf");
' Install IronPdf with Nuget:  PM> Install-Package IronPdf
Imports IronPdf

' Set Application scope Temp Path
Private MyTempPath = "C:\Safe\Location\"
Environment.SetEnvironmentVariable("TEMP", MyTempPath)
Environment.SetEnvironmentVariable("TMP", MyTempPath)

' Set IronPDF Temp Path
IronPdf.Installation.TempFolderPath = Path.Combine(MyTempPath,"IronPdfTemp")

' Your PDF Generation and editing code here
Dim Renderer = New IronPdf.HtmlToPdf()
Dim doc = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>")
doc.SaveAs("example.pdf")

IronPDF will occasionally generate Temporary files while rendering and editing PDF documents. This is unavoidable.

We can set IronPdf.Installation.TempFolderPath to work around this also, tho the Environmental TempPath Directory may still sometimes be used in some cases by 3rd party packages.

To control this we can set the TempPath Environmental Variable application wide in C# on application startup.