Deleting file problem

Hi,


Our service picks up excel file from file system and attempting to open it, if we get any errors from open() (such as file is protected) we get an exception and than we trying to delete the file. Delete() throws an exception saying that the file is “being used”.
I do not see any Close() in Excel object. What should we do?

Here is a simple C# form sample to see the problem. (does not have to be a service)
Take any excel file and make it password protected or anything else to cause Open() to fail with an exception


private void button2_Click(object sender, System.EventArgs e)
{
string fIn = textBox1.Text;
Excel excel1 = new Excel();
try
{
excel1.Open(fIn);
}
catch(Exception ex)
{
string x = ex.Message;
}
finally
{
try
{
File.Delete(fIn);
}
catch(Exception ex1)
{
string x2 = ex1.Message;
}
}
}



Dear Mark,

Yes. If an exception is thrown, I should close it internally. I have fixed it. Thanks for your feedback.

Because I am doing some other enhancement, I will release it within one week. Now thanks for your patience.

If you’re too urgent to wait for it please let me know.

@mark,
We have discontinued Aspose.Excel and introduced a new product Aspose.Cells which contains all the latest features in MS Excel and much more better in performance.

For more information on loading, saving, converting and management of Excel files please follow the link below:
Loading, Saving, Converting and Managing

Download the latest version of Aspose.Cells for .NET from the following link:
Aspose.Cells for .NET (Latest Version)

You can download the latest demos here.