For Programmers: Free Programming Magazines  


Home > Archive > Delphi > March 2004 > How to get path to the application file ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to get path to the application file ?
HJK

2004-03-27, 12:21 am

I'm writing a Delphi application which do some file operations in the same
folder as the exe
file is placed but I also do some outside that path.

Some of my oprations fails after browsing to files outside the same folder
as the exe
file because then the current path is probably changed

Is there a simple way of getting the path to the exe file ?

I would like to open the file with

Exe_file_path+'\myfile.txt'


Justus J.

2004-03-27, 12:21 am

....
>
> Is there a simple way of getting the path to the exe file ?
>
> I would like to open the file with
>
> Exe_file_path+'\myfile.txt'
>
>


ExtractFilePath(ParamStr(0)) + 'myfile.txt'

should work.

In a GUI app, you can allso use Application.ExeName in stead of ParamStr(0)
(Application being an automatically created TApplication instance, see
online help).

Justus J.


Jud McCranie

2004-03-27, 12:21 am

On Sun, 14 Mar 2004 12:38:54 +0100, "HJK" <nospam@online.no> wrote:

>Is there a simple way of getting the path to the exe file ?


Yes, you can get the path with ExtractFilePath( application.ExeName)


---
Replace you know what by j to email
Jud McCranie

2004-03-27, 12:21 am

On Sun, 14 Mar 2004 10:46:54 -0500, Jud McCranie
<youknowwhat.mccranie@adelphia.net> wrote:

>Yes, you can get the path with ExtractFilePath( application.ExeName)


BTW, application.ExeName is not a generic name, so use
"application.ExeName" specifically. application is type TApplication,
and ExeName is a property of it.

---
Replace you know what by j to email
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com