devxlogo

Get the canonical name of a file

Get the canonical name of a file

In many cases you may need the canonical (or absolute) name of a file, for example when you need to compare two relative file names (relative to the current directory or drive, that is) and decide whether they point to the same or different files.

You can obtain the canonical path of a file using an API call, but the FileSystemObject object offers a better and simpler way:

' NOTE: this code requires that you add a reference to the'       Microsoft Scripting Runtime type libraryFunction GetAbsolutePath(ByVal FileName As String) As String    Dim fso As New Scripting.FileSystemObject    GetAbsolutePath = fso.GetAbsolutePathName(FileName)End Function

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist