PDA

Click to See Complete Forum and Search --> : File access with Application Paths


colm.leavy
Jan 24th, 2000, 06:58 PM
Does anyone know how to use AppPath properly?

I have created a setup file for my application and it will only work if users install it in a certain directory. I have been trying to use the $(AppPath) in the code and it simply won't work

E.G. I have a directory testfiles as a subdirectory of the installation directory.
At the moment in the code, I access files in that directory directly by c:\MyApplication\testfiles\whatever.file
but I would like a way to be able to access it as
(installation directory)\testfiles\whatever.file

I know this can be done using $(AppPath) but have not found the correct way of doing this.
Any of you out there got examples of how this can be done?

Thanks.

RogerH
Jan 24th, 2000, 07:06 PM
I usually use the following code:


Dim FileName as String

FileName = App.Path
If Right$(FileName, 1) <> "\" Then FileName = FileName & "\"
FileName = FileName & "testfiles\whatever.file"


------------------

colm.leavy
Jan 24th, 2000, 08:00 PM
If you don't know what the path to the file is going to be before hand, then that won't work, thanks anyway.

Crazy D
Jan 24th, 2000, 08:11 PM
Did you test it??
App.Path returns the path where the program is installed...
And if everything else fails, modify setup1.exe (source comes with VB), and save the path where the program is installed in the registry (useless though since app.path does the trick...)

colm.leavy
Jan 24th, 2000, 08:31 PM
No I didn't.
I just didn't read it properly, not with it today, sorry about that. Thanks again.