FileSystem.GetFileInfo Method
Returns a FileInfo object for the specified file.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
Parameters
- file
- Type: System.String
Name and path of the file.
| Exception | Condition |
|---|---|
| ArgumentException |
The path name is malformed. For example, it contains invalid characters or is only white space. The file name has a trailing slash mark. |
| ArgumentNullException |
file is Nothing or an empty string. |
| NotSupportedException |
The path contains a colon in the middle of the string. |
| PathTooLongException |
The path is too long. |
| SecurityException |
The user lacks necessary permissions. |
| UnauthorizedAccessException |
The user lacks ACL (access control list) access to the file. |
An exception is not thrown if the file does not exist; rather, it will be thrown the first time the object's properties are accessed.
The following table lists examples of tasks involving the My.Computer.FileSystem.GetFileInfo method.
|
To |
See |
|
To get information about a file |
|
|
Determine a file's name and path |
This example retrieves a System.IO.FileInfo object for the file MyLogFile.log and uses it to report the file's full name, last access time, and length.
-
FileIOPermission
Controls the ability to access files and folders. Associated enumeration: Unrestricted.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.