# remove()

Canonical URL: https://developers.iagenify.com/ar/sdk/ref/local-files/remove/
Language: ar

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

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

Status: free · recursive on a folder · no recycle bin

## المعاملات {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `target` | string | مطلوب | الـ ملفّ أو مجلد إلى حذف الـ عمل هامشي جذر هو. |

```javascript
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");
```

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

## مكان العمل نفسه مرفوض {#root}

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

## النسخة المستردة {#recoverable}

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

```javascript
const stamp = new Date().toISOString().replace(/[:.]/g, "-");

// Reversible
await pc.files.move(path, `.trash/${stamp}/${path}`);

// Final
await pc.files.remove(path);
```

## الأخطاء {#errors}

| الرمز | الحالة | متى |
| --- | --- | --- |
| path_not_found | 404 | لا شيء في ذلك الطريق، محو مرتين من هذا يُثير هذا في المرة الثانية |
| invalid_path | 400 | مُطلقة، خارج مساحة العمل، أو الجذر. |
| local_files_require_node | 400 | لا تتوفر في بيئة التشغيل منظومة ملفات. |
| storage_not_on_this_machine | 409 | حاسوب آخر يخزن |

```javascript
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;
  }
}
```

- [move()](/ar/sdk/ref/local-files/move): الطريقة العكسية لجعل شيء يذهب بعيداً
- [محارف محلية](/ar/sdk/ref/local-files): مساحة العمل، قواعد المسار، والشكل كل طريقة ترجع.

```python
pc.files.remove("Launch plan/draft.md")
# {"ok": True}

# A folder goes with its contents, at every depth
pc.files.remove("Archive/2026")
```

```python
# Reversible: trash() moves it under .trash/<stamp>/
pc.files.trash(path)

# Final
pc.files.remove(path)
```

```python
def remove_if_there(files, path):
    if not (files.root / path).exists():
        return False
    files.remove(path)
    return True
```
