Ho do I retrieve the path of my current working directory?
I have this VB exe file in any given folder. When I execute it, I want for it to store the path in which it is saved.
And also, I only want the path... I do NOT want the path + filename.
I tried using CurDir, but that only returns the default path for Visual Basic.
Example:
Private Sub cmdCurrentPath_Click()
MsgBox "The current path is: " + CurDir
End Sub
The message box will always say : C:\VC6\VB98
Thanks.
Warning, if you are offended by the mention of FSO, do not read
I will jump out of the way of the rocks that will be thrown my way, but one way to do it is with the FileSystemObject. Add the Microsoft Scripting Runtime to your project and use the following code.
VB Code:
Private Sub Command1_Click()
Dim fso As FileSystemObject
Set fso = New FileSystemObject
MsgBox fso.GetParentFolderName(App.Path)
Set fso = Nothing
End Sub