FileSystemObject.GetFileName Method (VB6)

Named Arguments

Yes

Syntax

oFileSysObj.GetFileName (Path)

oFileSysObj

Use: Required

Data Type: FileSystemObject object

Any object variable returning a FileSystemObject object.

Path

Use: Required

Data Type: String

A path specifier.

Return Value

A String value.

Description

Returns the filename element of a given path.

Rules at a Glance

  • If the filename can't be determined from the given Path, a zero-length string ("") is returned.

  • Path can be a relative or an absolute reference.

Programming Tips and Gotchas

  • GetFileName doesn't verify that a given file exists in Path.

  • Path can be a network drive or share.

  • GetFileName has no built-in intelligence; it assumes that the last element of the string that isn't part of a drive specifier is, in fact, a filename. As with all the GetxName methods of the FileSystemObject object, the GetFileName method is more a string-manipulation routine than an object-related routine.

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.