My.Computer.FileSystem.GetDirectoryInfo Method
Returns a DirectoryInfo object for the specified path.
' Usage
Dim value As System.IO.DirectoryInfo = My.Computer.FileSystem.GetDirectoryInfo(directory)
' Declaration
Public Function GetDirectoryInfo( _
ByVal directory As String _
) As System.IO.DirectoryInfo
Parameters
- directory
String. Path of directory. Required.
Return Value
Exceptions
The following conditions may cause an exception:
The directory path is not valid for one of the following reasons: it is a zero-length string; it contains only white space; it contains invalid characters; or it is a device path (starts with \\.\) (ArgumentException).
The directory path is not valid because it is Nothing (ArgumentNullException).
The directory path exceeds the system-defined maximum length (PathTooLongException).
A file or directory name in the directory path contains a colon (:) or is in an invalid format (NotSupportedException).
The user lacks necessary permissions to view the directory path (SecurityException).
Remarks
If the directory does not exist, an exception is not thrown until the first time a property on the DirectoryInfo object is accessed.
Tasks
The following table lists examples of tasks involving the My.Computer.FileSystem.GetDirectoryInfo method.
To |
See |
---|---|
Determine when a directory was created |
How to: Determine a Directory's Creation Time in Visual Basic |
Determine whether a directory is read-only |
How to: Determine if a Directory is Read-Only in Visual Basic |
Example
This example gets a DirectoryInfo object for the directory C:\Documents and Settings and displays the directory's creation time, last access time, and last write time.
Dim getInfo As System.IO.DirectoryInfo
getInfo = My.Computer.FileSystem.GetDirectoryInfo _
(My.Computer.FileSystem.SpecialDirectories.MyDocuments)
MsgBox("The directory was created at " & getInfo.CreationTime)
MsgBox("The directory was last accessed at " & getInfo.LastAccessTime)
MsgBox("The directory was last written to at " & getInfo.LastWriteTime)
Requirements
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 |
Permissions
The following permission may be necessary:
Permission |
Description |
---|---|
Controls the ability to access files and folders. Associated enumeration: Unrestricted. |
For more information, see Code Access Security and Requesting Permissions.