The compact and repair way in Access is to compress a new file, delete the original file, and then rename it. You can use the DAO Engine to do the same. As far as I can tell from MS Visual C # 2010 Express, you can set a link to the DAO and use this:
var MyDBE=new DAO.DBEngine(); MyDBE.CompactDatabase("c:\\docs\\Mybe.mdb", "c:\\docs\\temp.mdb");
To prevent the database from being used, you can check if .ldb exists.
Sorry, but I don't know anything about C #, so these notes are very rude.
source share