getDir
Category: Storage
Namespace: web.storage.getDir
Description
Returns the full Windows path to the app's dedicated storage folder. Useful when you need to pass the storage path to other APIs such as web.variables.saveVariables, web.files.writeTextFile, or web.shell.showInExplorer.
Syntax
const dir = await web.storage.getDir();
Parameters
None
Returns
Promise<string> - Full path to the storage folder with a trailing backslash, e.g.:
C:\Users\Alice\AppData\Local\ezWareLab\WebExeBuilder\{AppGUID}\storage\
Example
Simple example
const dir = await web.storage.getDir();
console.log('Storage folder:', dir);
Practical example — use with web.variables for game saves
// Cache at startup — only fetch once
let storageDir = '';
document.addEventListener('DOMContentLoaded', async () => {
storageDir = await web.storage.getDir();
await web.variables.loadVariables(storageDir + 'progress.json');
});
async function saveProgress() {
await web.variables.saveVariables(storageDir + 'progress.json');
}
Advanced example — open storage folder in Explorer
const dir = await web.storage.getDir();
await web.shell.showInExplorer({ path: dir });
Performance Tips
- Cache the result at startup — the path never changes during a session
- Avoid calling
getDir()on every save/load; call it once and store in a variable
let storageDir = '';
async function initStorage() {
storageDir = await web.storage.getDir();
}
Related Methods
web.storage.writeFile()- Write a file using just a name (no path needed)web.storage.readFile()- Read a file using just a name (no path needed)web.storage.listFiles()- List files using just names (no path needed)web.directory.getAppDataDir()- Returns the parent app data folder (one level up)
Notes
- The path always ends with a trailing backslash — safe to concatenate a file name directly:
storageDir + 'file.json' - The storage folder is created automatically at app startup —
getDir()will always return a valid, existing path - The path is unique per app GUID — two different WebExeBuilder apps never share the same storage folder