This documentation is archived and is not being maintained.

CurDir Function

Returns a string representing the current path.

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

Parameter

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/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"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: Microsoft Visual Basic .NET Runtime (in MicrosoftVisualBasic.dll)

See Also

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

Show: