Export (0) Print
Expand All

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.

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.

This function returns a string representing the current path.

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".

This function is not supported.

Namespace: Microsoft.VisualBasic

Module: FileSystem

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

Community Additions

ADD
Show:
© 2014 Microsoft