T
T
TCloud2018-04-27 23:33:44
Delphi
TCloud, 2018-04-27 23:33:44

How to get rid of absolute paths?

Hello dear.
I am writing a program - a test for knowledge of "Something there".
And now I store the files from which I take the full answer to the question, in the .txt format . I specify
the absolute path to them.
But how to find the desired file without using an absolute path?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey delphinpro, 2018-04-27
@OTCloud

// Создаем свойство в форме

private
  AppPath: string;

// при создании вычисляем его

procedure TfmMain.FormCreate(Sender: TObject);
begin
  AppPath := ExtractFilePath(Application.ExeName);
  //…

// потом используем
  DBName := AppPath + '\' + 'base.sqlite';

S
Saboteur, 2018-04-27
@saboteur_kiev

Use relative path.
Or use a variable/config with something like $MY_APP_HOME, which points to the folder with your program. Configured once during installation and then something like $MY_APP_HOME/answers/*.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question