|Modify your test so it breaks out of the loop as soon as a match is found
for (int j = 0; j < excelSheets.Length; j++)
if (excelSheets[j] == "Sheet1$")
Match = true;
//delete the following lines after the loop
if (Match == true)
// add this line after the finally block
You could actually check the names in your
foreach block to make it more efficient.
One of these days I'm going to think of a really clever signature.