Exemple #1
0
        // Token: 0x0600027F RID: 639 RVA: 0x00009424 File Offset: 0x00007624
        public static void ShrinkAccess()
        {
            DbConfigInfo dbConfig = DbConfigs.GetDbConfig();
            string       mapPath  = FPUtils.GetMapPath(WebConfig.WebPath + dbConfig.dbpath);
            string       mapPath2 = FPUtils.GetMapPath(WebConfig.WebPath + "cache/temp/");

            if (!File.Exists(mapPath))
            {
                throw new Exception("目标数据库不存在,无法压缩");
            }
            if (!Directory.Exists(mapPath2))
            {
                Directory.CreateDirectory(mapPath2);
            }
            if (File.Exists(mapPath2 + Path.GetFileName(mapPath)))
            {
                File.Delete(mapPath2 + Path.GetFileName(mapPath));
            }
            string         destconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mapPath2 + Path.GetFileName(mapPath);
            JetEngineClass jetEngineClass = new JetEngineClass();

            jetEngineClass.CompactDatabase(dbConfig.connectionstring, destconnection);
            File.Copy(mapPath2 + Path.GetFileName(mapPath), mapPath, true);
            File.Delete(mapPath2 + Path.GetFileName(mapPath));
        }
Exemple #2
0
        /// <summary>
        /// Compresser la DB
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void btnCompression_Click(object sender, EventArgs e)
        {
            if (!File.Exists(_dbName))
            {
                return;
            }

            JetEngine jro = new JetEngineClass();

            string newDb = _dbName + ".cpr";

            try
            {
                jro.CompactDatabase(string.Format(_conStringCompressTemplate, _dbName), string.Format(_conStringCompressTemplate, newDb));
                File.Delete(_dbName);
                File.Move(newDb, _dbName);
                txtErr.Text = string.Format(Resources.INF_COMPRESSION_COMPLETE);
            }
            catch (Exception exp)
            {
                txtErr.Text = string.Format(string.Format(Resources.ERR_CANNOT_COMPACT, exp.Message));
            }
        }