where is CDbf4File.Compress()

Sep 17, 2013 at 8:43 PM
I know a record can be marked as deleted, but how do I actually delete it from the table.
In the DbfRecord class it says that in order to actually remove a record from the table the function CDbf4File.Compress()must be called, and actually all records flagged as deleted will be removed from the table.

The problem is where is the function CDbf4File.Compress()?

I have looked the whole library and the internet and after 2 week I have had no success!
Nov 4, 2013 at 6:01 PM
I added my own pack method to the DBFFile source and recompiled:
        /// <summary>
        /// Pack the current open database.
        /// </summary>
        public void Pack()
            if (!this.mRecordDeleted) return;

            if (this.IsForwardOnly)  throw new InvalidOperationException("Cannot pack forward-only streams.");

            if (!this.mHeaderWritten) throw new InvalidOperationException("Must have an existing DBF to pack.");

            var record = new DbfRecord(this.Header);
            uint nextPackedRecord = 0;
            for (uint i = 0; i < this.Header.RecordCount; ++i)
                this.Read(i, record);
                if (!record.IsDeleted)
                    if (record.RecordIndex != nextPackedRecord)
                        record.RecordIndex = nextPackedRecord;
                        this.Write(record, true);


            this.Header.RecordCount = nextPackedRecord;

            // Set the end position of the DBF file scrapping the records after the 
            // last non deleted record.
            uint nNewEndOfFile = this.Header.HeaderLength + (this.Header.RecordCount * this.Header.RecordLength);

            this.mRecordDeleted = false;