Visual Basic Language Reference  

CurDir Function

Returns a string representing the current path.

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

Parameter

Drive
Optional. String 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/Errors

Exception type Error number Condition
IOException 68 Drive is not found.
ArgumentException 68 Invalid Drive is specified.

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")   ' Returns "C:\WINDOWS\SYSTEM".
MyPath = CurDir("D")   ' Returns "D:\EXCEL".

See Also

ChDir Function | ChDrive Function | MkDir Function | RmDir Function | IOException | ArgumentException