محارف محلية

mkdir()

files.mkdir(dir) → Promise<Item>

ينشئ مجلداً، وكلّ منافذ يحتاجها. يُغيّر مُنَسَّق على مجلد موجود بالفعل.

freecreates parentsidempotent
Using Python?

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

المعاملات

dirstringمطلوب

المجلد المراد إرساؤه، نسبي إلى مساحة العمل. إنّ جذر هذا العمل هو الذي يُرفض.

await pc.files.mkdir("Clients/Acme/2026");
// { name: "2026", path: "Clients/Acme/2026", type: "folder", size: null, mimeType: null, modifiedAt: "…" }

// Calling it again changes nothing and still answers
await pc.files.mkdir("Clients/Acme/2026");
pc.files.mkdir("Clients/Acme/2026")
# {"path": "Clients/Acme/2026"}

# Calling it again changes nothing and still answers
pc.files.mkdir("Clients/Acme/2026")

:: تنشأ الوالدين

Clients and Clients/Acme are created if they are not there. So a tree is one call, not one call per level — and an existing folder along the way is left exactly as it is.

أنت نادراً ما تحتاج إليه

(دِ هذا الأمر

Mkdir() هو لـ a فارغ مجلد تريد أن تكون موجود من تلقاء نفسه -- وجهة معدة مسبقاً ، هيكل معروض في واجهة. لكتابة ملف ، اذهب مباشرة إلى الكتابة().

الأخطاء

الرمزالحالةمتى
invalid_path400مُطلقة، خارج مساحة العمل، أو جذر مكان العمل.
local_files_require_node400لا تتوفر في بيئة التشغيل منظومة ملفات.
storage_not_on_this_machine409حاسوب آخر يخزن

A المسار الذي يُسمّي موجود & لا شيء هو خطأ في نظام الملفات، وليس أحد خطأينا: نظام التشغيل يرفض جعل مجلد حيث يجلس الملف، و يأتي الرسالة من خلاله.