Question : Check ik file exist

Dear experts,

I have this to load and save the 3 listviews to file.

procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  SaveListViewToFile(lstvGlucose, 'Glucose.sav');
  SaveListViewToFile(lstvBolus, 'Bolus.sav');
  SaveListViewToFile(lstvFoodDB, 'FoodDB.sav');
end;
(*---------------------------------------------------*)
procedure TMainForm.FormCreate(Sender: TObject);
begin
  LoadListViewToFile(lstvGlucose, 'Glucose.sav');
  LoadListViewToFile(lstvBolus, 'Bolus.sav');
  LoadListViewToFile(lstvFoodDB, 'FoodDB.sav');
end;

But when I start my application the first time the files doesn't exits yet.
so, I get 3 times a error message. How can I prevent this.
That the programm first look if the fileexist otherwist create it.

P

Answer : Check ik file exist

Founded solution is very creative, but by default the files will be saved in (or loaded from) applications folder therefore
   ExtractFilePath(Application.ExeName)    is   unnecessary.
Random Solutions  
 
programming4us programming4us