EasyXLS
http://forum.easyxls.com/

File Handle Lock
http://forum.easyxls.com/viewtopic.php?f=5&t=139
Page 1 of 1

Author:  levi [ Wed Jan 16, 2008 11:38 am ]
Post subject:  File Handle Lock

I am trying to read an already created Excel file and immediately write it out to disk as another file, however when this happens there seems to be a file handle left open as I cannot delete the file. I open Process Explorer and it seems that for some reason the indexing service (cidaemon.exe) keeps a handle to this file always open. I am also testing other libraries and this does not happen. The code snippet is listed here:

Code:
EasyXLS.ExcelDocument xlsDoc = new ExcelDocument();                               
xlsDoc.easy_LoadXLSFile("whatever.xls");                               
xlsDoc.easy_WriteXLSFile("whatever(EasyXLS).xls");
xlsDoc.Dispose();

Author:  daniela [ Thu Jan 17, 2008 6:20 am ]
Post subject: 

The easy_LoadXLSFile and easy_WriteXLSFile methods close the streams at the end. The issue is caused by something else.

Author:  levi [ Thu Jan 17, 2008 8:35 am ]
Post subject: 

Daniela wrote:
The easy_LoadXLSFile and easy_WriteXLSFile methods close the streams at the end. The issue is caused by something else.


And that something else being what? Can you offer any insight as to what I might be doing wrong with my code? This seems to happen quite frequently for me with the .NET version (C#).

Author:  daniela [ Thu Jan 17, 2008 12:10 pm ]
Post subject: 

Is it possible to open later the XLS file generated with EasyXLS with a different application or even with your program that you are writing?

Author:  levi [ Thu Jan 17, 2008 1:34 pm ]
Post subject: 

Daniela wrote:
Is it possible to open later the XLS file generated with EasyXLS with a different application or even with your program that you are writing?


You can open it in Excel, however it opens Read Only. What my program does is if I try to open a file called "MyFile.xls", it'll load the file and then save the file as "MyFile(EasyXLS).xls". Once the "MyFile(EasyXLS).xls" file is locked, and my program runs again to do the same thing, rather than taking 13 minutes (please see issue http://forum.easyxls.com/viewtopic.php?t=130) it takes 2 seconds to run because (I believe) the write fails because the file is locked, however I don't receive any sort of exception even though the easy_WriteXLSFile method is failing. I will do more research to see if I can recreate this scenario.

Author:  levi [ Thu Jan 17, 2008 3:42 pm ]
Post subject: 

I cannot get this to happen again. I'm not sure what was going on before, it is possible that I was not using the Dispose() method before, but I don't think that was the case. Regardless, I have ran this a few times and have not come across it again.

In regard to this:

Quote:
the write fails because the file is locked, however I don't receive any sort of exception even though the easy_WriteXLSFile method is failing.


I noticed that you can retrieve error messages. I just assumed that since read/write methods were returning void that if an error occurred it would throw an Exception.[/i]

Author:  daniela [ Fri Jan 18, 2008 5:27 am ]
Post subject: 

Check also ExcelDOcument.easy_getError method for errors.

Page 1 of 1 All times are UTC - 4 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/