|
-
Aug 31st, 2001, 09:53 AM
#1
Thread Starter
New Member
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.
-
Aug 31st, 2001, 10:00 AM
#2
Frenzied Member
app.path returns the path where the exe is running
-
Aug 31st, 2001, 10:03 AM
#3
Fanatic Member
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
-
Aug 31st, 2001, 10:10 AM
#4
Frenzied Member
Why do people hate the FSO so much? Is it because of the reference?
-
Aug 31st, 2001, 10:15 AM
#5
Fanatic Member
Yes. "Some" programmers take offense to using FSO because it involves distributing an additional dll. But they do not hesitate to recommend using other controls that involve using dll's that are a lot larger than scrrun.dll.
Go figure.
-
Aug 31st, 2001, 10:40 AM
#6
Frenzied Member
Why use FSO when u can just use app.Path???????????
IS there any thing wrong with app.path? Please let me know!
-
Aug 31st, 2001, 10:45 AM
#7
Fanatic Member
The problem with app.path is that it does not use FSO .
My fault, my fault. App.Path is a beautiful solution. When I answered the question I was working on a project where the folder name and the exe name were the same, so I should have paid attention to what I was doing. I mistakenly thought that app.path was including the exe name too.
Sorry for the confusion. Besides, it is a Friday and I am just waiting to get out of here.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|