Parâmetros
targetstringobrigatórioIl file o il dossier da cancellare. La radice del workspace è renied.
await pc.files.remove("Launch plan/draft.md");
// { ok: true }
// A folder goes with its contents, at every depth
await pc.files.remove("Archive/2026");pc.files.remove("Launch plan/draft.md")
# {"ok": True}
# A folder goes with its contents, at every depth
pc.files.remove("Archive/2026")Non vi è negoziat in un dosari che non è vazio, e non lista di ce che va. Se si volve sa, lista prima; se lo vore de volta, move a parte in lugar.
L'espazio di lavoro in se stesso è negat
remove("") levant invalid_path. Vaziar l'area de lavoro non è una operazion que questa classe offre — contiene i files de ogni applicazione de quella macchina, non solo i tuoi.
La versiòn recuperabile
Preferì un move in un folder ocult ogni qualquuna che il sentiero venisse da un model, da un form, o da nòmòstu cosa che non ti calcute. Costa lo stesso e è reversible.
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
// Reversible
await pc.files.move(path, `.trash/${stamp}/${path}`);
// Final
await pc.files.remove(path);# Reversible: trash() moves it under .trash/<stamp>/
pc.files.trash(path)
# Final
pc.files.remove(path)Erros
| Código | Status | Quando |
|---|---|---|
| path_not_found | 404 | Nada in quel sentiero. Eliminare due volte eleva questo la seconda vez. |
| invalid_path | 400 | Absolute, fuori del luogo de lavoro, o la radice. |
| local_files_require_node | 400 | O ambiente de execução não tem sistema de arquivos. |
| storage_not_on_this_machine | 409 | Un altro computer's stoccage. |
import { IaGenifyError } from "iagenify";
async function removeIfThere(files, path) {
try {
await files.remove(path);
return true;
} catch (err) {
if (err instanceof IaGenifyError && err.code === "path_not_found") return false;
throw err;
}
}def remove_if_there(files, path):
if not (files.root / path).exists():
return False
files.remove(path)
return True