Dear all,
I think I have a simular problem. When creating a file and reading it using a OleDBConnection, I can not remove it afterwards. I am using conn.Close(), the 'using' statement, ... It keeps giving the 'file already in use' error when trying to delete it...
I placed a file "test.xlsx_copy" on my desktop and copied it, just to make sure the file is not used anywhere else... It also does also not matter where I put the file (temp folder, desktop, ...), it keeps giving the error. I am not using any antivirus, the windows antivirus is turned off.... I have no idea what can cause this problem and how to fix it...
Anyone who can help me (or give an update on the previous problem)? I would be very gratefull!
I think I have a simular problem. When creating a file and reading it using a OleDBConnection, I can not remove it afterwards. I am using conn.Close(), the 'using' statement, ... It keeps giving the 'file already in use' error when trying to delete it...
I placed a file "test.xlsx_copy" on my desktop and copied it, just to make sure the file is not used anywhere else... It also does also not matter where I put the file (temp folder, desktop, ...), it keeps giving the error. I am not using any antivirus, the windows antivirus is turned off.... I have no idea what can cause this problem and how to fix it...
C#:
string filename = "C:\\Users\\Koen\\Desktop\\test.xlsx";
File.Copy(filename + "_copy", filename);
string strConnectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";", filename);
using (OleDbConnection SQLConn = new OleDbConnection(strConnectionString))
{
SQLConn.Open();
SQLConn.Close();
}
File.Delete(filename);
Anyone who can help me (or give an update on the previous problem)? I would be very gratefull!