In a C# 2010 windows application that I am writing, I am accessing excel 2010 spreadsheets. I am obtaining information about the data contained within the excel spreadsheet from the file name.
My problem occurs when an excel spreadsheet has been openend and not closed properly by the application. The program actually aborts. When I try to access these particular spreadsheets again, there is a try call error that occurs.
Is there some code I can write to check to make certain the excel spreadsheet is ok and there is no problem with the file? If so, can you show me the code and/or point me to a link that will show me how to solve this problem?
Is there code to check the excel file to see if it's OK?
No, not really.
You need to write your code to handle the situation where it's not. This includes properly wrapping sensitive sections of your code that deals with opening, reading, and closing the Excel file and properly handling those exceptions according to your business rules for processing the file.