getAppDataDir
Category: Directory Operations
Namespace: web.directory.getAppDataDir
Description
Retrieves the application's data directory in the user's AppData folder. This is the recommended location for storing application settings and user data.
Syntax
const appDataDir = await web.directory.getAppDataDir();
Parameters
None
Returns
Promise<string> - Returns a promise that resolves with the full path to the application's data directory
Examples
Simple example
const appDataDir = await web.directory.getAppDataDir();
console.log('App data directory:', appDataDir);
// Output: C:\Users\YourName\AppData\Roaming\YourApp
Save user preferences
const appDataDir = await web.directory.getAppDataDir();
const prefsPath = appDataDir + '\\preferences.json';
const preferences = {
theme: 'dark',
language: 'en'
};
await web.files.writeTextFile({
filePath: prefsPath,
content: JSON.stringify(preferences, null, 2)
});
Use Cases
- Store user preferences and application settings
- Save application state between sessions
- Store user-specific data that persists across updates
Notes
- This is the standard Windows location for application data
- Data persists even when the application is updated
- Each user has their own separate AppData directory