パスの最後のコンポーネントのベース名を含む(ファイル拡張子を除いた)文字列を戻します。
構文
object.GetBaseName(path)
引数:
FileSystemObjectの名前。備考
GetBaseNameメソッドは、パス引数に一致するコンポーネントがない場合、長さゼロの文字列(" ")を戻します。
注:
GetBaseNameメソッドは、ファイル拡張子が付いた指定されたパス文字列に対してのみ機能します。パスの解決は試行されず、指定されたパスの存在も確認しません。
次の例では、GetBaseNameメソッドの使用方法を示します。
例1:
Function GetTheBase(filespec)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
GetTheBase = fso.GetBaseName(filespec)
End Function
' Usage
Dim baseName
baseName = GetTheBase("C:\testfile.txt")
' Output: testfile
例2:
Function GetTheBase(filespec)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
GetTheBase = fso.GetBaseName(filespec)
End Function
' Usage
Dim emptyPath
emptyPath = GetTheBase("")
' Output: ""