I create an Excel file using EPPlus library. After the file is created, it cannot be deleted or edited, as it is said to be used by "another user", as long as the program is running. I cannot find any solution that would work for me.
```
Here is my code:
var newFile = new FileInfo(path);
using (var xlPackage = new ExcelPackage(newFile))
{
var ws = xlPackage.Workbook.Worksheets.Add("Sheet1");
...
xlPackage.Save();
}
```
The strange thing is that I am able File.Delete() the newly created files from within my code. But I cannot delete or edit it while the program is still running from the Windows Explorer.
Comments: You should end the process of from Task Manager before going to do something with that excel file as the process is created by that program, so by the program you can edit/delete, but u cannot do this at the same time.
```
Here is my code:
var newFile = new FileInfo(path);
using (var xlPackage = new ExcelPackage(newFile))
{
var ws = xlPackage.Workbook.Worksheets.Add("Sheet1");
...
xlPackage.Save();
}
```
The strange thing is that I am able File.Delete() the newly created files from within my code. But I cannot delete or edit it while the program is still running from the Windows Explorer.
Comments: You should end the process of from Task Manager before going to do something with that excel file as the process is created by that program, so by the program you can edit/delete, but u cannot do this at the same time.