0

Hello all, I'm perplexed here really. This is in Delphi 7
I Have a snippet

var
U:string;
UserPath:string;
begin
U := GetCurrentUserName;

My get Username works fine calling on a function I wrote however when I am attempting to insert that username in a directory path it wont place the ending???

procedure TSpUser.SpeedButton7Click(Sender: TObject);
var
U:string;
UserPath:string;
begin
U := GetCurrentUserName;
UserPath := 'C:\Documents and Settings\' + (U) + '\Local Settings\Temp\';
PlaySound('type', hInstance, SND_RESOURCE or SND_SYNC);
Label9.Caption:=UserPath;
end;

What I get is C:\Documents and Settings\users name but the \Local Settings\Temp\ just wont show????
Am I missing something really simple here?

Thanks if you can help

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by ebi1
0

The code looks fine to me.

Are you sure there isn't an extraneous #0 at the end of U?

Hey Duoas. Thank for reading.
No anything extra. This little problem is sending me nannas lol.
I've even broken the line into three seperate String and done an individual read on all and get exactly what is needed but when I attempt to join it all together ....fizzzzle

0

try to add :
ShowMessage('-'+U+'-');
Exit;

After the "U := GetCurrentUserName;" line.

i use that way to debug sometimes.
Using a BreakPoint (F5) wont show you if you have a Space or a CRLF.
if you do have that, then maybe you can try :
UserPath := 'C:\Documents and Settings\' + Trim(U) + '\Local Settings\Temp\';

if you do have a Space or a CRLF in the U, then i would check that GetCurrentUserName function if i were you.

i use the Trim function a lot, just to be on the safe side.

good luck :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.