How to access user directory in lazarus? -


After

I am trying to open file changelog.txt and it does not matter if I open it Need to have the user open it though it is always located in the ~ / directory. Enter the file here. Here is my code:

  Process TForm1.FormCreate (From: TObject); Var myFile: textfile; Line: String; Start AssignFile (myFile, '~ / changelog.txt'); Reset (myFile); While EOF (MyFile) does not readLn (myFile, Line); Label3.Caption: = (Label3.Capttion + Line + # 13 # 10); End; CloseFile (myFile); End;  

This does not work, however, if I replace ~ with the actual user name, then it works, however, I use the username of each user Can not know which will run my program. Any idea how can I get the username that started the program? ! Thanks

Edit1: I have tried this, but this also includes a new line:

  RunCommand ('/ bin / bash', ['- - C ',' Whoami '], users);  

This is normal. The concept of "~" is an shell level and thus requires a separate shell elevator for evaluation. Assignfile kernel interface is not directly understood though and thus this thing is not understood.

Use ('home') to get the homedir from the environment. Better also allows to get home dior in a crossplat way.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -