I am using 18.104.22.168 Aspose.Cells for.net.
Workbook w = new Workbook(filepath);
After a second again if same file path goes, it gives an below error
The process cannot access the file ‘’ because it is being used by another process.
How can we save and close/dispose the file?
Thanks for you quick response!
I completely got your point.
There are no excel application running in my task manager prior to running aspose code but when I save the file using below code
Workbook w = new Workbook(filepath); //sample.xls
the excel file (sample.xls) process stays open in task manager meaning it is not being close.
and If I again run the same code using sample.xls file it will throw the same error.
I am looking for solution to close the excel file after processing is done.
In Microsoft.Office.Interop.Excel we have follwing options to close and quit the excel
It looks very strange as you got this issue, we do not find this issue at all. The issue does not seem to me related to Aspose.Cells APIs rather it is specific to your pc or some processes/applications you have started. Please note, Aspose.Cells has Workbook.Dispose method to manually free the resources, etc. which has been added in newer versions, therefore if you are using any older version of the API, please upgrade to latest version in order to use this method. Also, you may give the following line of code a try at the end if it makes any difference:
w = null;
If you still find the issue, kindly create a simple console application with our latest version/fix (v17.3.x) to reproduce the issue on our end, we will check it soon.
Note: To evaluate your issue precisely, we got to reproduce it on our end first.
I tried using latest version still getting same error.
I am using Aspose.cells Version : 19.8.0 . Today i am also facing same kind of issue.Although it was working fine before. This file is not opened anywhere nor excel application is open…
Code used to save:
var filePath = Path.Combine(Path.GetTempPath(), fileName);
The process cannot access the file ‘C:\\windows\\TEMP\\RateSheetTemplate_20200909.xlsx’ because it is being used by another process.
Is there any way to solve this ?
I guess your file “RateSheetTemplate_20200909.xlsx” might be opened in the background by some process, MS Excel or application (for which you do not know about it). So, you must release the file from other processes/applications, so, Aspose.Cells could save the file fine.
By the way, could you try to save/re-save the file by different name (e.g “RateSheetTemplate_20200909_1.xlsx”) if it works or not?
On server there was no process using this document.
I deleted the saved file with same name and tried again…Its working fine now…
But I am looking for safe solution if this happen again in future.
Maybe you have some multi-threaded applications or environment which are using the file and multiple requests are saving/accessing the same file. Anyways, this is not an issue with Aspose.Cells APIs. Also, to provide a solution to your issue, we need to reproduce it on our end first and set it as a bug.
I am processing many files, sequentially. After doing Document.Save on all of them, I then need to open the pdfs and move them. Getting this “process cannot access because being used by another process” error. Please provide a way to release/dispose the handle/object
Which Aspose API you are using? Are you using Aspose.PDF?