LoginSignup
2
2

More than 5 years have passed since last update.

ファイルパスを表す文字列から親のフォルダ部分を取り出す関数

Last updated at Posted at 2015-01-03

車輪の再発明してる感が半端ないが応用が効きそうなのでメモ。

function getParentDir(byval path)
    dim splitedPath
    splitedPath = split(path, "\")
    splitedPath(ubound(splitedPath)) = ""
    getParentDir = join(splitedPath, "\")
end function

msgbox getParentDir("C:\hoge\fuga\poge.txt")
' C:\hoge\fuga\

msgbox getParentDir("\\hoge\fuga\poge.txt")
' \\hoge\fuga\

msgbox getParentDir("\\192.168.0.100\hoge\fuga\poge.txt")
' \\192.168.0.100\hoge\fuga\

2
2
0

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
2
2