WebExeBuilder Documentation

getTempDir

Category: Directory Operations

Namespace: web.directory.getTempDir

Description

Retrieves the system's temporary directory path. Use this for storing temporary files that can be safely deleted.

Syntax

const tempDir = await web.directory.getTempDir();

Parameters

None

Returns

Promise<string> - Returns a promise that resolves with the full path to the system's temporary directory

Examples

Simple example

const tempDir = await web.directory.getTempDir();
console.log('Temp directory:', tempDir);
// Output: C:\Users\YourName\AppData\Local\Temp

Create temporary file

const tempDir = await web.directory.getTempDir();
const tempFile = tempDir + '\\temp_' + Date.now() + '.txt';

await web.files.writeTextFile({
    filePath: tempFile,
    content: 'Temporary data'
});

// Use the temp file...

// Clean up when done
await web.files.deleteFile({ filePath: tempFile });

Use Cases

  • Store temporary files during processing
  • Cache downloaded data temporarily
  • Create working files that don't need to persist

Notes

  • Files in the temp directory may be automatically deleted by the system
  • Always clean up temporary files when you're done with them
  • Use unique filenames (e.g., with timestamps) to avoid conflicts