Script Paradigm

ファイルパスからフォルダパスを取得

ファイルパスからフォルダパスを抽出します。

Option Explicit
MsgBox fnGetFolderPathByFilePath("C:\abc\test.txt")
Function fnGetFolderPathByFilePath(ByVal strPath)
    Dim lIdx
    Dim strName
    
    lIdx = InStrRev(Replace(strPath,"/","\"), "\")
    If lIdx > 0 Then
        strName = Left(strPath, lIdx)
    Else
        strName = strPath
    End If
    
    fnGetFolderPathByFilePath = strName
End Function
Copyright © 2006 Hikijishi All Rights Reserved.
[] [wsh][0.00208282470703125]