Method: GetFileName for FileSystemObject
- Updated2024-09-12
- 1 minute(s) read
FileSystemObject and Dictionary > Methods > Method: GetFileName for FileSystemObject
Method: GetFileName for FileSystemObject
Returns the part of the path that corresponds with the name of a file or a folder.
sGetFileName = Object.GetFileName(Path)
| Object | FileSystemObject Object with this method |
| Path | String Specifies the path. The path must neither correspond with an existing folder nor with an existing file. |
| sGetFileName | String Receives the filename or the folder name. |
The following example specifies the filename or the folder name in a path:
Function GetName(sDrive) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") GetName = fso.GetFileName(sDrive) End Function