Cara melewati jalur file dalam fungsi javascript

Modul node:path_ menyediakan utilitas untuk bekerja dengan jalur file dan direktori. Itu dapat diakses menggunakan

Show
const path = require('node:path');

Windows vs. POSIX

Operasi default modul node:path bervariasi berdasarkan sistem operasi di mana Node. aplikasi js sedang berjalan. Khususnya, saat dijalankan pada sistem operasi Windows, modul node:path akan menganggap bahwa jalur gaya Windows sedang digunakan

Jadi menggunakan path.basename() mungkin menghasilkan hasil yang berbeda pada POSIX dan Windows

Di POSIX

Di Windows

Untuk mencapai hasil yang konsisten saat bekerja dengan jalur file Windows di sistem operasi apa pun, gunakan

Di POSIX dan Windows

Untuk mencapai hasil yang konsisten saat bekerja dengan jalur file POSIX di sistem operasi apa pun, gunakan

Di POSIX dan Windows

Di Node Windows. js mengikuti konsep direktori kerja per-drive. Perilaku ini dapat diamati saat menggunakan jalur drive tanpa garis miring terbalik. Misalnya, path.resolve('C:\\') berpotensi mengembalikan hasil yang berbeda dari

┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
0. Untuk informasi lebih lanjut, lihat

┌─────────────────────┬────────────┐ │ dir │ base │ ├──────┬ ├──────┬─────┤ │ root │ │ name │ ext │ " / home/user/dir / file .txt " └──────┴──────────────┴──────┴─────┘ (All spaces in the "" line should be ignored. They are purely for formatting.)_1

HistoryVersionChangesv6. 0. 0

Melewati non-string sebagai argumen

┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
2 akan dilontarkan sekarang

v0. 1. 25

Ditambahkan. v0. 1. 25

Metode path.basename() mengembalikan bagian terakhir dari

┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
2, mirip dengan perintah Unix
┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
5. Trailing diabaikan

Meskipun Windows biasanya memperlakukan nama file, termasuk ekstensi file, dengan cara yang tidak peka huruf besar-kecil, fungsi ini tidak. Misalnya,

┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
6 dan
┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
7 merujuk ke file yang sama, tetapi
┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
5 memperlakukan ekstensi sebagai string peka huruf besar-kecil

A dilemparkan jika

┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
_2 bukan string atau jika
┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
" C:\      path\dir   \ file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
1 diberikan dan bukan string

┌─────────────────────┬────────────┐ │ dir │ base │ ├──────┬ ├──────┬─────┤ │ root │ │ name │ ext │ " C:\ path\dir \ file .txt " └──────┴──────────────┴──────┴─────┘ (All spaces in the "" line should be ignored. They are purely for formatting.)_2

Menyediakan pembatas jalur khusus platform

Misalnya, pada POSIX

Di Windows

┌─────────────────────┬────────────┐ │ dir │ base │ ├──────┬ ├──────┬─────┤ │ root │ │ name │ ext │ " C:\ path\dir \ file .txt " └──────┴──────────────┴──────┴─────┘ (All spaces in the "" line should be ignored. They are purely for formatting.)_3

HistoryVersionChangesv6. 0. 0

Melewati non-string sebagai argumen

┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
2 akan dilontarkan sekarang

v0. 1. 16

Ditambahkan. v0. 1. 16

Metode

┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
" C:\      path\dir   \ file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
_5 mengembalikan nama direktori dari
┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
2, mirip dengan perintah Unix
┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
" C:\      path\dir   \ file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
7. Pemisah direktori trailing diabaikan, lihat

A dilempar jika

┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
2 bukan string

node:path_1

HistoryVersionChangesv6. 0. 0

Melewati non-string sebagai argumen

┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
2 akan dilontarkan sekarang

v0. 1. 25

Ditambahkan. v0. 1. 25

Metode node:path_3 mengembalikan ekstensi

┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
2, dari kemunculan terakhir karakter node:path5 (titik) hingga akhir string di bagian terakhir dari
┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
2. Jika tidak ada node:path5 di bagian terakhir
┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
2, atau jika tidak ada node:path5 karakter selain karakter pertama dari nama dasar
┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
2 (lihat path.basename()) , string kosong dikembalikan

A dilempar jika

┌─────────────────────┬────────────┐
│          dir        │    base    │
├──────┬              ├──────┬─────┤
│ root │              │ name │ ext │
"  /    home/user/dir / file  .txt "
└──────┴──────────────┴──────┴─────┘
(All spaces in the "" line should be ignored. They are purely for formatting.)
2 bukan string

node:path_4

HistoryVersionChangesv19. 0. 0

Titik akan ditambahkan jika tidak ditentukan dalam node:path5

v0. 11. 15

Ditambahkan. v0. 11. 15

  • node:path6 Objek JavaScript apa pun yang memiliki properti berikut
  • Pengembalian.
  • Metode node:path_7 mengembalikan string jalur dari objek. Ini kebalikan dari

    Saat memberikan properti ke node:path_6 ingat bahwa ada kombinasi di mana satu properti memiliki prioritas di atas yang lain

    • node:path0 diabaikan jika node:path1 diberikan
    • node:path2 dan node:path3 diabaikan jika node:path4 ada

    Misalnya, pada POSIX

    Di Windows

    node:path_5

    Metode node:path_6 menentukan apakah

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 adalah jalur absolut

    Jika

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 yang diberikan adalah string dengan panjang nol, node:path9 akan dikembalikan

    Misalnya, pada POSIX

    Di Windows

    A dilempar jika

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 bukan string

    path.basename()_2

    Metode path.basename()_3 menggabungkan semua

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 segmen yang diberikan bersama-sama menggunakan pemisah khusus platform sebagai pembatas, lalu menormalkan jalur yang dihasilkan

    Segmen

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 panjang-nol diabaikan. Jika string jalur yang digabungkan adalah string dengan panjang nol maka path.basename()6 akan dikembalikan, mewakili direktori kerja saat ini

    A dilempar jika salah satu segmen jalur bukan string

    path.basename()_8

    Metode path.basename()_9 menormalkan

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 yang diberikan, menyelesaikan segmen path.win321 dan path.basename()6

    Ketika banyak, karakter pemisahan segmen jalur berurutan ditemukan (mis. g. path.win32_3 di POSIX dan path.win324 atau path.win323 di Windows), mereka digantikan oleh satu contoh pemisah segmen jalur khusus platform (path.win323 di POSIX dan path.win324 di Windows). Pemisah trailing dipertahankan

    Jika

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    _2 adalah string dengan panjang nol, path.basename()6 dikembalikan, mewakili direktori kerja saat ini

    Misalnya, pada POSIX

    Di Windows

    Karena Windows mengenali banyak pemisah jalur, kedua pemisah tersebut akan digantikan oleh contoh pemisah pilihan Windows (path.win324)

    A dilempar jika

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 bukan string

    path.posix_3

    Metode node:path_8 mengembalikan objek yang propertinya mewakili elemen signifikan dari

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2. Pemisah direktori trailing diabaikan, lihat

    Objek yang dikembalikan akan memiliki properti berikut

    Misalnya, pada POSIX

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    _

    Di Windows

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    " C:\      path\dir   \ file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)

    A dilempar jika

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 bukan string

    path.posix

    HistoryVersionChangesv15. 3. 0

    Terekspos sebagai path.resolve('C:\\')0

    v0. 11. 15

    Ditambahkan. v0. 11. 15

    Properti path.posix menyediakan akses ke implementasi spesifik POSIX dari metode

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2

    API dapat diakses melalui path.resolve('C:\\')3 atau path.resolve('C:\\')4

    path.resolve('C:\\')5

    HistoryVersionChangesv6. 8. 0

    Di Windows, garis miring utama untuk jalur UNC kini disertakan dalam nilai kembalian

    v0. 5. 0

    Ditambahkan. v0. 5. 0

    Metode path.resolve('C:\\')_6 mengembalikan jalur relatif dari path.resolve('C:\\')7 ke path.resolve('C:\\')8 berdasarkan direktori kerja saat ini. Jika path.resolve('C:\\')7 dan path.resolve('C:\\')8 masing-masing memutuskan ke jalur yang sama (setelah memanggil

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    01 pada masing-masing), string dengan panjang nol dikembalikan

    Jika string dengan panjang nol diteruskan sebagai path.resolve('C:\\')7 atau path.resolve('C:\\')8, direktori kerja saat ini akan digunakan sebagai pengganti string dengan panjang nol

    Misalnya, pada POSIX

    Di Windows

    A dilemparkan jika path.resolve('C:\\')_7 atau path.resolve('C:\\')8 bukan string

    ┌─────────────────────┬────────────┐ │ dir │ base │ ├──────┬ ├──────┬─────┤ │ root │ │ name │ ext │ " / home/user/dir / file .txt " └──────┴──────────────┴──────┴─────┘ (All spaces in the "" line should be ignored. They are purely for formatting.)_07

    Metode

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    01 menyelesaikan urutan jalur atau segmen jalur menjadi jalur absolut

    Urutan jalur yang diberikan diproses dari kanan ke kiri, dengan masing-masing

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 berikutnya ditambahkan sampai jalur absolut dibangun. Misalnya, mengingat urutan segmen jalur.
    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    _10,
    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    11,
    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    12, memanggil
    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    13 akan mengembalikan
    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    14 karena
    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    15 bukan jalur absolut tetapi
    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    16 adalah

    Jika, setelah memproses semua

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    _2 segmen, jalur absolut belum dibuat, direktori kerja saat ini digunakan

    Jalur yang dihasilkan dinormalisasi dan garis miring yang tertinggal dihapus kecuali jalur diselesaikan ke direktori root

    Segmen

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 panjang-nol diabaikan

    Jika tidak ada

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 segmen yang dilewati,
    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    01 akan mengembalikan jalur absolut dari direktori kerja saat ini

    A dilemparkan jika salah satu argumen bukan string

    ┌─────────────────────┬────────────┐ │ dir │ base │ ├──────┬ ├──────┬─────┤ │ root │ │ name │ ext │ " C:\ path\dir \ file .txt " └──────┴──────────────┴──────┴─────┘ (All spaces in the "" line should be ignored. They are purely for formatting.)_8

    Menyediakan pemisah segmen jalur khusus platform

    Misalnya, pada POSIX

    Di Windows

    Di Windows, garis miring ke depan (path.win323) dan garis miring ke belakang (path.win324) diterima sebagai pemisah segmen jalur;

    ┌─────────────────────┬────────────┐ │ dir │ base │ ├──────┬ ├──────┬─────┤ │ root │ │ name │ ext │ " / home/user/dir / file .txt " └──────┴──────────────┴──────┴─────┘ (All spaces in the "" line should be ignored. They are purely for formatting.)_27

    Hanya pada sistem Windows, menampilkan yang setara untuk

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 yang diberikan. Jika
    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    _2 bukan string,
    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 akan dikembalikan tanpa modifikasi

    Metode ini bermakna hanya pada sistem Windows. Pada sistem POSIX, metode ini non-operasional dan selalu mengembalikan

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2 tanpa modifikasi

    path.win32

    HistoryVersionChangesv15. 3. 0

    Terekspos sebagai

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    _33

    v0. 11. 15

    Ditambahkan. v0. 11. 15

    Properti path.win32 menyediakan akses ke implementasi khusus Windows dari metode

    ┌─────────────────────┬────────────┐
    │          dir        │    base    │
    ├──────┬              ├──────┬─────┤
    │ root │              │ name │ ext │
    "  /    home/user/dir / file  .txt "
    └──────┴──────────────┴──────┴─────┘
    (All spaces in the "" line should be ignored. They are purely for formatting.)
    2

    Bagaimana cara meneruskan lokasi file dalam JavaScript?

    function Cetak Aplikasi() { Aplikasi. PrintApplication(applicationID, function (berhasil, saveFileLocation) { jika (berhasil) { dokumen. lokasi = '/Aplikasi/Unduh File/' + saveFileLocation;

    Bagaimana cara melewatkan file sebagai argumen di js?

    buka = ​​function(file) { var rawFile = new XMLHttpRequest(); . open("GET", file, false);

    Bagaimana cara meneruskan jalur file ke URL?

    Kita akan menggunakan metode toURL() dan toURI() dari kelas File. .
    Program. konversi jalur file lokal ke URL & URI di Java (contoh) package org. mempelajari. io; . io. Mengajukan; . bersih. MalformedURLException;.
    Keluaran. konversi jalur file lokal ke URL & URI di java (contoh) 1. File mutlak. D. \Code\LocalFilePath. txt. 2

    Bagaimana cara mendapatkan jalur lokal di JavaScript?

    jendela. lokasi. pathname mengembalikan path dan nama file dari halaman saat ini.