需要在工程中引用COM组件: Microsoft Jet and Replication Objects Library ,示例请参考下面的函数: public static bool CompactJetDatabase(string fileName) { // I use this function as part of an AJAX page, so rather than throwing // exceptions if errors are encountered, I simply return false and allow the page // to handle the failure generically. try { if (fileName.Equals("")) return false; string oldFileName = fileName; // 创建一个生成后的临时文件 string newFileName = Path.Combine(Path.GetDirectoryName(oldFileName), Guid.NewGuid().ToString("N") + ".mdb"); // 创建压缩类 JetEngineClass engine = new JetEngineClass(); // 压缩MDB为新的文件 engine.CompactDatabase( String.Format(AccessOleDbConnectionStringFormat, oldFileName), String.Format(AccessOleDbConnectionStringFormat, newFileName)); // 删除旧文件 File.Delete(oldFileName); // 改名为旧文件名. File.Move(newFileName, oldFileName); return true; } catch (Exception ex) { return false; } } 要进行压缩的文件 string ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=文件名"; string rootpath = 文件名.Substring(0,文件名.LastIndexOf("//")); //连接字符串 string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="; //对象参数 object[] oParams; //实例化一个Activator对象参数 object objJRO = Activator.CreateInstance(Type.GetTypeFromProgID("JRO.JetEngine")); //文件格式 if(Flag==true) //97格式 oParams = new object[]{ ConnString, connStr+rootpath+"/tempdb.mdb;Jet OLEDB:Engine Type=4"}; else //97以上格式 oParams = new object[]{ ConnString, connStr+rootpath+"/tempdb.mdb"}; //对Activator对象进行参数设置 objJRO.GetType().InvokeMember("CompactDatabase",System.Reflection.BindingFlags.InvokeMethod,null,objJRO,oParams); //删除文件 System.IO.File.Delete(filename); System.IO.File.Move(rootpath+"/tempdb.mdb",filename); //压缩文件 System.Runtime.InteropServices.Marshal.ReleaseComObject(objJRO); //清空 objJRO = null; http://hi.baidu.com/hpping/blog/item/f635fbdc9c7faeafcd1166f1.html