WebExeBuilder Documentation

getUserDocumentsDir

Category: Directory Operations

Namespace: web.directory.getUserDocumentsDir

Description

Retrieves the path to the current user's Documents directory.

Syntax

const documentsPath = await web.directory.getUserDocumentsDir();

Parameters

None

Returns

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

Examples

Simple example

const documentsPath = await web.directory.getUserDocumentsDir();
console.log('Documents directory:', documentsPath);
// Output: C:\Users\YourName\Documents

Save report to Documents

const documentsPath = await web.directory.getUserDocumentsDir();
const reportPath = documentsPath + '\\report.txt';

await web.files.writeTextFile({
    filePath: reportPath,
    content: 'Monthly Report\n\nSales: $10,000'
});

Use Cases

  • Save user documents to the standard Documents folder
  • Provide a default location for file save dialogs
  • Access user-created documents

Notes

  • Returns the full absolute path to the Documents directory
  • Path format is Windows-style with backslashes
  • This is the standard location users expect for document files