E
Evgeny Zoldin
Hi ALL,
I do in C# the following:
bool DoSomething(){
OleDbConnection conn = new OleDbConnection( "... connection string to
MS_Access.mdb ... ");
/* do what I need using OleDbDataAdapter, DataTable etc... */
conn.Close();
GC.Collect(); // !!!!! - gives no effect for the the following
statements
File.Move( ".. old location..." + MS_Access.mdb, "...new location..." +
MS_Access.mdb); // -- throws exception !!!!!
// System.IO.IOException: The process cannot access the file ""... new
location..." + MS_Access.mdb" because it is being used by another process.
// But <"... new location..." + MS_Access.mdb> does not exist at all !!!
// and I see that <""... old location..." + MS_Access.ldb"> still eists,
i.e. call conn.Close() does not release the file
.......
}
If I call just before File.Move(...)
MessageBox.Show( " message " );
than the file <""... old location..." + MS_Access.ldb"> disappears and
<""... old location..." + MS_Access.mdb"> being released and File.Move(...)
works fine.
What the reason of that behaviour? As I did the similar in VB6 by means of
ADO it worked correct without MsgBox(...)...
Thanx for any help
Evgeny
I do in C# the following:
bool DoSomething(){
OleDbConnection conn = new OleDbConnection( "... connection string to
MS_Access.mdb ... ");
/* do what I need using OleDbDataAdapter, DataTable etc... */
conn.Close();
GC.Collect(); // !!!!! - gives no effect for the the following
statements
File.Move( ".. old location..." + MS_Access.mdb, "...new location..." +
MS_Access.mdb); // -- throws exception !!!!!
// System.IO.IOException: The process cannot access the file ""... new
location..." + MS_Access.mdb" because it is being used by another process.
// But <"... new location..." + MS_Access.mdb> does not exist at all !!!
// and I see that <""... old location..." + MS_Access.ldb"> still eists,
i.e. call conn.Close() does not release the file
.......
}
If I call just before File.Move(...)
MessageBox.Show( " message " );
than the file <""... old location..." + MS_Access.ldb"> disappears and
<""... old location..." + MS_Access.mdb"> being released and File.Move(...)
works fine.
What the reason of that behaviour? As I did the similar in VB6 by means of
ADO it worked correct without MsgBox(...)...
Thanx for any help
Evgeny