|
-
Jul 3rd, 2000, 05:16 PM
#1
Thread Starter
Hyperactive Member
i've wanted to know how to get the directory of a program using the app.path command ... how would i go about it?
-
Jul 3rd, 2000, 05:41 PM
#2
_______
using app.path
Dim AppPath$
If Right(App.Path, 1) <> "\" Then _
AppPath = App.Path & "\" _
Else AppPath = App.Path
End If
use this when you store all your app files in one dir
then when calling a file you simpley say
Open AppPath & Myfile.txt for append as # 1
that way..if the folder is stored on another pc
under D:\yourstuff\mystuff\xyz
the application will find it cause it looks for
myfile.txt in the app path which is the path where
the folder is stored..
Yea...hopefully I haven't confused you to death..
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 3rd, 2000, 05:52 PM
#3
Thread Starter
Hyperactive Member
lol
u lost me after dim apppath$
-
Jul 3rd, 2000, 06:02 PM
#4
If by "directory of a program" you mean the folder where the program is installed, then assuming that the program is installed in c:\xyz then
MsgBox App.Path & "\" & "myfile.txt" would display
c:\xyz\myfile.txt
-
Jul 3rd, 2000, 06:05 PM
#5
Lively Member
HeSaidJoe had a few extra lines in his code to make sure if the app is in the root folder, it wouldn't return "C:\\" instead of "C:\"
It's safer that way.
Andrew Empson
vb6(ent) SP4
-
Jul 3rd, 2000, 06:11 PM
#6
Thread Starter
Hyperactive Member
i just want to know
i just want to know the directory of where the user might have put my program in ... lets say "c:\xyz\prog.exe"
that way when i get the directory then i could tell my program to play a music file that came with the program which should be in the same directory n if not then don't play it ...
-
Jul 3rd, 2000, 06:12 PM
#7
_______
reverse
If you write and app and don't use app.path
and for arguments sake we store your files
in c:\yourfolder
We then take your app and install it on my pc
but on my pc I put your app in D:\myfolder
When I go to run your app I will get errors
on file not found because the path's will be
different even though the file names are the
same.
If you use app.path then app.path is the path
the app is stored in so regardless of where it
is stored it will look for yourfile.txt and
find it as long as it is stored in the folder
where your app is stored.
When I dim AppPath I am just creating
an instance of App.Path and if the App.Path
doesn't have a \ on the end of it I am putting
one there. I then use AppPath instead of App.Path
Just habit..you could just as easily just add
the \ to the end of App.Path if it wasn't there
That is the best I can do at explaining the function
App.Path
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
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
|