GetFileName Method

 

Description

 

Returns the last component of specified path that is not part of the drive specification.

 

PowerBASIC Syntax

 

METHOD GetFileName ( _

BYVAL bstrPathSpec AS STRING _

) AS STRING

 

Arguments

 

bstrPathSpec

BSTR. The path (absolute or relative) to a specific file.

 

Return Value

 

BSTR. The name of the file.

 

Remarks

 

The GetFileName method returns a zero-length string ("") if bstrPathSpec does not end with the named component. The GetFileName method works only on the provided path string. It does not attempt to resolve the path, nor does it check for the existence of the specified path.

 

Example [PowerBASIC]

 

#INCLUDE "windows.inc"

#INCLUDE "scrrun.inc"

 

DIM fso AS IFileSystem

DIM strName AS STRING

 

' Create an instance of the FileSystemObject

fso = NEWCOM "Scripting.FileSystemObject"

' Get the file name from a path

strName = fso.GetFileName(UCODE$("C:\MyFolder\Test.txt"))

 

Valid XHTML 1.0 Transitional