LoginSignup
1
0

More than 5 years have passed since last update.

Windowsでもglobで取得するパスは「/」区切り、、、でハマった

Posted at

Windowsでもglobで取得するパスは例えば

let jpgPath = 'C:/hoge/fuga.jpg'

と言った感じで/区切りになる。
ところがpath.sepはWindowsでは\となるのでsplitが期待通りにならない。
そこで、

path.join(jpgPath)

とすると/\に変換されるので

let array = path.join(jpgPath).split(path.sep)

splitが期待通りに動いてくれる。

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0