WebExeBuilder Documentation

deleteFile

Category: Storage

Namespace: web.storage.deleteFile

Description

Delete a file from the app's dedicated storage folder. If the file does not exist, the call succeeds silently.

Syntax

await web.storage.deleteFile({ name: 'filename.ext' });

Parameters

Parameter Type Required Description
name string Yes File name only (e.g. save1.json)

Returns

Promise<boolean> - Resolves true on success

Example

Simple example

await web.storage.deleteFile({ name: 'save1.json' });

Practical example — delete a save slot

async function deleteSave(slot) {
    const confirmed = confirm(`Delete save slot ${slot}?`);
    if (!confirmed) return;
    await web.storage.deleteFile({ name: `save${slot}.json` });
    refreshSaveSlotUI();
}

Advanced example — clean up old temp files

async function cleanupTempFiles() {
    const files = await web.storage.listFiles();
    for (const name of files) {
        if (name.startsWith('temp_')) {
            await web.storage.deleteFile({ name });
        }
    }
}
  • web.storage.writeFile() - Write a file to the storage folder
  • web.storage.readFile() - Read a file from the storage folder
  • web.storage.listFiles() - List all files in the storage folder

Notes

  • Deleting a file that does not exist is not an error — it resolves true silently
  • This operation cannot be undone