listFiles
Category: Storage
Namespace: web.storage.listFiles
Description
Returns an array of file names currently in the app's dedicated storage folder. The internal key-value store file (storage.json) is excluded from the results.
Syntax
const files = await web.storage.listFiles();
Parameters
None
Returns
Promise<string[]> - Array of file name strings. Empty array [] if no files exist.
Example
Simple example
const files = await web.storage.listFiles();
console.log('Storage files:', files);
// e.g. ["save1.json", "save2.json", "config.json"]
Practical example — populate a save slot picker
async function showSaveSlots() {
const files = await web.storage.listFiles();
const saveFiles = files.filter(f => f.startsWith('save') && f.endsWith('.json'));
const list = document.getElementById('save-list');
list.innerHTML = '';
if (saveFiles.length === 0) {
list.innerHTML = '<li>No saves found</li>';
return;
}
for (const name of saveFiles) {
const li = document.createElement('li');
li.textContent = name;
li.onclick = () => loadGame(name);
list.appendChild(li);
}
}
Advanced example — storage usage summary
async function storageSummary() {
const files = await web.storage.listFiles();
const keys = await web.storage.keys();
console.log(`Files: ${files.length} — ${files.join(', ')}`);
console.log(`KV keys: ${keys.length} — ${keys.join(', ')}`);
}
Related Methods
web.storage.writeFile()- Write a file to the storage folderweb.storage.readFile()- Read a file from the storage folderweb.storage.deleteFile()- Delete a file from the storage folderweb.storage.getDir()- Get the full path to the storage folder
Notes
- Returns file names only, not full paths — use
getDir()if you need the full path storage.json(the key-value store file) is always excluded from results- Returns an empty array (not null) when no files exist
- Order of files is not guaranteed