Solved

Any alternative for CurDir?

Posted on 2004-08-22
5
428 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now