?
Solved

Any alternative for CurDir?

Posted on 2004-08-22
5
Medium Priority
?
454 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
Farzad Akbarnejad earned 80 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

801 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