I assume that your variable Usernamecontains # 0 at the end and you output this variable to a specific Windows API function. For example, the following code will result in this incorrect behavior:
procedure TForm1.Button1Click(Sender: TObject);
var
Dir: string;
Username: string;
begin
Username := 'Username' + #0;
Dir := Concat('C:\Users\', Username, '\Downloads\done.txt');
ShowMessage(Dir);
end;
My suggestion is to check the value of your variable Usernameand remove the extra # 0 at the end, if any.
TLama source
share