Reputation: 13
How I get the user download folder path using Inno Setup?
[Code]
function InitializeSetup(): Boolean;
begin
if (FileExists(ExpandConstant('{%username%}\Downloads\file.txt'))) then
begin
MsgBox('Installation validated', mbInformation, MB_OK);
Result := True;
end
else
begin
MsgBox('Abort installation', mbCriticalError, MB_OK);
Result := False;
end;
end;
This always came to end in else
part.
There is constant for "user docs" and "user desktop" but not for "download". Can anyone please help me how I get user "download" folder path.
Upvotes: 1
Views: 341
Reputation: 202282
The syntax for resolving environment variable is {%NAME}
, not {%NAME%}
. Moreover the USERNAME
environment variable is not a path, it's just a username. You want USERPROFILE
instead:
ExpandConstant('{%USERPROFILE}\Downloads\file.txt')
And hard-coding a path to Downloads
folder seem like a bad idea to me. Who guarantees you that the file is there? I personally never download anything to the Downloads
folder.
Aren't you actually looking for a file that is downloaded to the same folder, where your installer was downloaded to? Use {src}
constant:
ExpandConstant('{src}\file.txt')
See Create small setup installer just for wizard, rest of files apart
Upvotes: 1