When application use a certain file, and there are some needs to use the previous file in many reason. In that case, Windows Registry is useful.
Below code is an example to Save/Load such kind of information.
const CK_APPLICATION_TITLE='LP-Employee Assessment'; function TMainFrm.LoadConfiguration:Boolean; var myReg: TRegistry; begin Result := False; myReg := TRegistry.Create( KEY_READ); try myReg.RootKey := HKEY_CURRENT_USER; // or HKEY_LOCAL_MACHINE if myReg.OpenKey( 'Software\' + CK_APPLICATION_TITLE + '\', true) then try OpenDialog1.FileName := myReg.ReadString('filename'); Result := TRUE; finally myReg.CloseKey; end; finally myReg.Free; end; end; procedure TMainFrm.SaveConfiguration; var myReg: TRegistry; begin myReg := TRegistry.Create( KEY_SET_VALUE); try myReg.RootKey := HKEY_CURRENT_USER; // or HKEY_LOCAL_MACHINE if myReg.OpenKey( 'Software\' + CK_APPLICATION_TITLE + '\', true) then try myReg.WriteString('filename', SaveDialog1.Filename); finally myReg.CloseKey; end; finally myReg.Free; end; end;