Home > Net >  Delete specific record from file of records
Delete specific record from file of records

Time:05-15

I have the next data structure :

 Type
 TMyRecord=Record
                 Num:String[50];
                 ID:String[50];
   
 End;

and I have a file of record Like the next :

Var
F:File of TMyRecord;

the file will contains many records , how I can delete one specific record from the file.

Thank you in advance .

CodePudding user response:

If the record is at the very end of the file, you can simply truncate the size of the file to omit the record.

Otherwise, the only way to delete a record from the beginning/middle of the file is to create a new file, copy the existing records from the old file to the new file omitting the record you want to delete, and then replace the old file with the new file.

  • Related