[Kylix] How do I determine the home directory?
Posted on 2002-06-09
How can I determine programatically what the current "home" directory is? I tried this:
procedure TForm1.Button1Click(Sender: TObject);
with TStringList.Create do
Add('This is a test!');
In UNIX/Linux, the "~/" should represent the user's home directory. However, Kylix doesn't seem to see it that way. I then tried replacing the "~/TestFile.txt" with "/home/edsteele/TestFile.txt" and that worked. The problem is that if another person runs the program, this won't be their home directory.
The value of the current user's home directory is stored in an environment variable called "HOME". Barring a better solution, how can I read the value of environment variables?