Solved

Any alternative for CurDir?

Posted on 2004-08-22
5
429 Views
Last Modified: 2012-06-27
Good day. I am having a problem with CurDir function, which return the path to current directory. It appeared that it's not reliable. Sometime it will point to the path to my desktop, even though my VB application is at another location.

http://support.microsoft.com/default.aspx?scid=kb;en-us;80611 also discussed about the reliability of CurDir.

Is there an alternative other than CurDir without statically specified the application location (e.g. c:\programgroup\programname) ?

Thanks and hope to hear from you.
0
Comment
Question by:cwchan80
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
Farzad Akbarnejad earned 20 total points
ID: 11867572
Hi,
Use Path property of App object.

App.Path


-FA
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 11868445
You should use public or global variable, and when application starts, you should have code like this (remember App.Path)

Public AppPath as String

Sub Main
     AppPath = App.Path
     ......
     Form1.Show
End Sub

0
 
LVL 3

Expert Comment

by:aParser
ID: 11968065
You can also use the Scripting Runtime

Set o = New Scripting.FileSystemObject
Debug.Print o.GetFolder(".").Path

And I recently found a VB2TheMax "Tip of the Day" that helped me:
Get the Command$ value from inside an ActiveX DLL
http://www.devx.com/vb2themax/Tip/18377
...which is based on the GetCommandLine API.  I see no reason why it wouldn't work inside an executable.

I'm wondering if the CurDir points to your desktop when you launch the program from an icon on your desktop.
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 12378247
I think that my comment is correct answer but the Author must decide on correct answer.

-FA
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question