The simplest way to defragment a db4o file would be:
Defragment.Defrag("database.db4o");
Defragment.Defrag("database.db4o")
Ensure that the file is not opened by any other process or db4o instance.
This moves the file filename to filename.backup, then it create a defragmented version of this database at the original position. If the backup file already exists this an IOException is throw and no action will be taken.
You can also specify the backup filename manually:
Defragment.Defrag("database.db4o", "database.db4o.bak");
Defragment.Defrag("database.db4o", "database.db4o.bak")
For more detailed configuration of the defragmentation process, you can use a DefragmentConfig instance:
DefragmentConfig config = new DefragmentConfig("database.db4o"); Defragment.Defrag(config);
Dim config As New DefragmentConfig("database.db4o") Defragment.Defrag(config)
It's possible to use a more fine grained configuration for the deframentation process. See "Defragmentation Configuration"
Defragmentation can throw IOException in the following situations: