Compartilhar via


CurDir Function 

Returns a string representing the current path.

The My.Computer.FileSystem Object gives you greater productivity and performance in file I/O operations than CurDir. For more information, see My.Computer.FileSystem.CurrentDirectory Property.

Public Overloads Function CurDir([ ByVal Drive As Char ]) As String

Parameters

  • Drive
    Optional. Char expression that specifies an existing drive. If no drive is specified, or if Drive is a zero-length string (""), CurDir returns the path for the current drive.

Exceptions

Exception type Error number Condition

IOException

68

Drive is not found.

ArgumentException

68

Invalid Drive is specified.

See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the Number Property (Err Object).) However, when possible, you should consider replacing such error control with Structured Exception Handling Overview for Visual Basic.

Remarks

This function returns a string representing the current path.

Example

This example uses the CurDir function to return the current path.

' Assume current path on C drive is "C:\WINDOWS\SYSTEM".
' Assume current path on D drive is "D:\EXCEL".
' Assume C is the current drive.
Dim MyPath As String
MyPath = CurDir()   ' Returns "C:\WINDOWS\SYSTEM".
MyPath = CurDir("C"c)   ' Returns "C:\WINDOWS\SYSTEM".
MyPath = CurDir("D"c)   ' Returns "D:\EXCEL".

Smart Device Developer Notes

This function is not supported.

Requirements

Namespace: Microsoft.VisualBasic

Module: FileSystem

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

See Also

Reference

ChDir Function
ChDrive Function
MkDir Function
RmDir Function
IOException Class
ArgumentException Class