I create a sqlite db file. and i want del it after complete the operation.
eg:
<code>var path = AppDomain.CurrentDomain.BaseDirectory + "test.db";
using (var dbcontext = new MyDbContext())
{
var res = dbcontext.Test.Add(new TestType { Name = "222", Id = 8, Test = false });
dbcontext.SaveChanges();
dbcontext.DisposeAsync();
}
var a = new CreateDbFileHelper();
GC.Collect(0);
GC.WaitForPendingFinalizers();
GC.WaitForFullGCComplete();
File.Delete(path);
</code>
<code>var path = AppDomain.CurrentDomain.BaseDirectory + "test.db";
using (var dbcontext = new MyDbContext())
{
var res = dbcontext.Test.Add(new TestType { Name = "222", Id = 8, Test = false });
dbcontext.SaveChanges();
dbcontext.DisposeAsync();
}
var a = new CreateDbFileHelper();
GC.Collect(0);
GC.WaitForPendingFinalizers();
GC.WaitForFullGCComplete();
File.Delete(path);
</code>
var path = AppDomain.CurrentDomain.BaseDirectory + "test.db";
using (var dbcontext = new MyDbContext())
{
var res = dbcontext.Test.Add(new TestType { Name = "222", Id = 8, Test = false });
dbcontext.SaveChanges();
dbcontext.DisposeAsync();
}
var a = new CreateDbFileHelper();
GC.Collect(0);
GC.WaitForPendingFinalizers();
GC.WaitForFullGCComplete();
File.Delete(path);
when i del this db file ,throw The process cannot access the file ,because it is being used by another process.
so what should i do to relaese conntion then del this file.
i try visable to use GC but it’s not work