Name
FileSystemObject.BuildPath Method
Syntax
oFileSysObj.BuildPath(Path,Name)
oFileSysObjUse: Required
Data Type: FileSystemObject object
A FileSystemObject object.
PathUse: Required
Data Type: String
A drive and/or folder path.
NameUse: Required
Data Type: String
The folder or file path to append to
path.
Return Value
A String.
Description
Creates a single string representing a path and filename or
simply a path by concatenating the path
parameter with the folder or filename, adding, where required, the
correct path separator for the host system.
Rules at a Glance
Pathcan be an absolute or relative path and doesn’t have to include the drive name.Neither
PathnorNamehas to currently exist.
Programming Tips and Gotchas
BuildPath is really a string concatenation method rather than a filesystem method; it does not check the validity of the new folder or filename. If you intend that the method’s return value be a path, you should check it by passing it to the FolderExists method; if you intend that the method’s return value be a path and filename, you should verify it by passing it to the FileExists method.
The only advantage to using the
BuildPathfunction as opposed to concatenating two strings manually is that the function selects the correct path separator.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access