/// <summary> /// Deletes the database. /// </summary> public void Dispose() { var filePath = new FileInfo(dataSourcePath); if (!filePath.Exists) { return; } sharedConnection.Dispose(); sqLiteConnection.Dispose(); SQLiteConnection.ClearAllPools(); // SQLite requires all created sql connection/command objects to be disposed // in order to delete the database file GC.Collect(2, GCCollectionMode.Forced); System.Threading.Thread.Sleep(100); File.Delete(dataSourcePath); }
private void ResetCache() { gtileCache = Path.Combine(cache, "TileDBv5") + Path.DirectorySeparatorChar; dir = gtileCache + GMapProvider.LanguageStr + Path.DirectorySeparatorChar; // precreate dir if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } #if !MONO SQLiteConnection.ClearAllPools(); #endif // make empty db { db = dir + (fileName != "" ? fileName : "Data.gmdb"); if (!File.Exists(db)) { Created = CreateEmptyDB(db); } else { Created = AlterDBAddTimeColumn(db); } CheckPreAllocation(); //var connBuilder = new SQLiteConnectionStringBuilder(); //connBuilder.DataSource = "c:\filePath.db"; //connBuilder.Version = 3; //connBuilder.PageSize = 4096; //connBuilder.JournalMode = SQLiteJournalModeEnum.Wal; //connBuilder.Pooling = true; //var x = connBuilder.ToString(); #if !MONO ConnectionString = string.Format("Data Source=\"{0}\";Page Size=32768;Pooling=True", db); //;Journal Mode=Wal #else ConnectionString = string.Format("Version=3,URI=file://{0},FailIfMissing=True,Page Size=32768,Pooling=True", db); #endif } // clear old attachments AttachedCaches.Clear(); RebuildFinnalSelect(); // attach all databases from main cache location #if !PocketPC var dbs = Directory.GetFiles(dir, "*.gmdb", SearchOption.AllDirectories); #else var dbs = Directory.GetFiles(dir, "*.gmdb"); #endif foreach (var d in dbs) { if (d != db) { Attach(d); } } }