GetFileInfo Method (My.Computer.FileSystem Object)
TOC
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

My.Computer.FileSystem.GetFileInfo Method 

Returns a FileInfo object for the specified file.


' Usage
Dim value As System.IO.FileInfo = My.Computer.FileSystem.GetFileInfo(file)
' Declaration
Public Function GetFileInfo( _
   ByVal file As String _
) As System.IO.FileInfo

Parameters

file

String. Name and path of the file. Required.

FileInfo

The following conditions may cause an exception:

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

How to: Get Information About a File in Visual Basic

Determine a file's name and path

How to: Parse File Paths in Visual Basic

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.

Dim information As System.IO.FileInfo
information = My.Computer.FileSystem.GetFileInfo("C:\MyLogFile.log")
MsgBox("The file's full name is " & information.FullName & ".")
MsgBox("Last access time is " & information.LastAccessTime & ".")
MsgBox("The length is " & information.Length & ".")

Namespace: Microsoft.VisualBasic.MyServices

Class: FileSystemProxy (provides access to FileSystem)

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

Yes

Windows Service

Yes

Web Site

Yes

The following permission may be necessary:

Permission Description

FileIOPermission

Controls the ability to access files and folders. Associated enumeration: Unrestricted.

For more information, see Code Access Security and Requesting Permissions.

Show:
© 2016 Microsoft