|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
How to: Determine the Absolute Path of a File in Visual Basic
Thereturns a object that can be used to determine information about a file, including its location, which is contained in the property.
If a file does not exist, GetFileInfo does not throw an exception, but one is thrown the first time a property on the System.IO.FileInfo object is accessed.
To determine the absolute path of a file
Use the GetFileInfo method to return a FileInfo object for the file you wish to examine. The FullName property contains the absolute path. The following example determines the absolute path of Test.txt and displays it in a message box.
The following conditions may cause an exception:
The path name is malformed. For example, it contains invalid characters or is only white space ().
The file does not exist or is Nothing ().
The path contains a colon in the middle of the string ().
The path is too long ().
The user lacks necessary permissions ().
The user lacks ACL (access control list) access to the file ().