Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB5,VB6,VBS
Expertise: beginner
Aug 9, 2001

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 library

Function GetAbsolutePath(ByVal FileName As String) As String
    Dim fso As New Scripting.FileSystemObject
    GetAbsolutePath = fso.GetAbsolutePathName(FileName)
End Function
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap