Im getting a I/O error 104 when reading TP (A file containing a Picture name)
procedure TfrmAvatar.FormShow(Sender: TObject);
var
sLocation:String;
TU, TP :textfile;
suser : string;
itemp:integer;
begin
Slocation:=ExtractFileDir(ExtractFileDir(ExtractFileDir(ParamStr(0))));
assignfile(TU,(slocation '\Username.txt'));
Reset(TU);
readln(TU, sUser);
edtUser.text:=suser;
closefile(TU);
assignfile(TP, (slocation '\Profile.txt'));
Reset(TP);
readln(TU, suser); //Getting 104 here on read
showmessage(sLocation suser);
imgAvatar.Picture.LoadFromFile(sLocation suser);
closefile(TP)
end;
Like I said above im simply reading one line from a assigned file TP
and i dont see where my mistake is if it is obvious just let me know
CodePudding user response:
You are reading from a closed file handle (TU
).
What you want to do is
readln(TP, suser);