I am opening an Excel file via
app = new Microsoft.Office.Interop.Excel.Application();
wb = app.Workbooks.Open(fromFile, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Then I am manipulating the cells, which works fine. I save the file to antother Folder, than I opened it in.
wb.SaveAs(toFile, Microsoft.Office.Interop.Excel.XlFileFormat.xlCSVWindows, Type.Missing, Type.Missing, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlLocalSessionChanges, false, Type.Missing, Type.Missing, true);
I Close the app and the workbook:
wb.Close(true, Type.Missing, Type.Missing);
app.Quit();
When I now want to move the original file by File.Move(), I get the error:
The process cannot access the file because it is being used by another
process.
Am I missing something?
edit:
Thank you very much guys. It has been the missing release of the objects.
Marshal.FinalReleaseComObject(object)
edit 2:
Well, but now I could run it once and now I always get the error:
This file is currently not available for use on this computer.
Combined with a COMException
The object invoked has disconnected from its clients.