محارف محلية

remove()

files.remove(target) → Promise<{ ok: true }>

يحذف a ملفّ أو a مجلد و الكل الإيطالية لا شيء و عمل فراغ جذر هو.

freerecursive on a folderno recycle bin
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

المعاملات

targetstringمطلوب

الـ ملفّ أو مجلد إلى حذف الـ عمل هامشي جذر هو.

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")
A مجلد هو مزال مع كل شيء فيه

لا يوجد رفض على مجلد ليس فارغ، ولا قائمة من ما ذهب. إذا أردت أن تعرف، قم بإعداده أولاً، إذا أردته أن يعود، قم بتحريكه إلى جانبه.

مكان العمل نفسه مرفوض

remove("") إثير invalid_path...إفراغ مساحة العمل ليست عملية تعرضها هذه الفئة -- إنها تحمل ملفات كل تطبيق على تلك الآلة، ليس فقط لك.

النسخة المستردة

يفضل الانتقال إلى مجلد مخفي عندما يأتي المسار من نموذج، من استمارة، أو من أي شيء لم تقم بحساب نفسك. يكلف نفسه وهو قابل للعكس.

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)

الأخطاء

الرمزالحالةمتى
path_not_found404لا شيء في ذلك الطريق، محو مرتين من هذا يُثير هذا في المرة الثانية
invalid_path400مُطلقة، خارج مساحة العمل، أو الجذر.
local_files_require_node400لا تتوفر في بيئة التشغيل منظومة ملفات.
storage_not_on_this_machine409حاسوب آخر يخزن
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