경로에서 마지막 구성요소의 기본 이름(파일 확장자 제외)이 포함된 문자열을 반환합니다.
구문
object.GetBaseName(path)
인수:
FileSystemObject의 이름입니다.주석
GetBaseName 메소드는 경로 인수와 일치하는 구성요소가 없는 경우 길이가 0인 문자열(" ")을 반환합니다.
주:
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: ""