I am trying to read a simple text file, but whenever I use the function LoadStringFromFile it always gives me
Type mismatch.
The text file that I am trying to read from contains a file path to a folder in User Documents. Something like c:\users\username\document\foldername\.
I know that Inno Setup has a directory constant for User Document, but the users don't have rights to install. When running the installer with admin account the directory constant would give a different file path. This text file has the real file path that I want to use for the installation.
function getPath(Param: String) : String;
var line: AnsiString;
begin
Result := LoadStringFromFile(ExpandConstant('{commonpf64}\appfolder\sometextfile.txt'), line);
end;
The
LoadStringFromFilefunction returnsBooleanvalue indicating success of the read. The actual contents is returned in theSargument (orlinein your code).Your function might look like: