Friday, September 14, 2018

Tip: ExcelDataReader returns "Invalid File Signature" when reading an Excel file.

Just happen to notice this problem when i am trying to load multiple Excel files from the same directory. The root cause for such error is simple for me, whenever I populate the file names using the "Directory.EnumerateFiles", it returns the Excel temporary file also, which the file name always start with a "~". So this file actually is not a valid Excel file, that's the reason when "AsDataset" function is called, it always throw error when the codes tried to load that extra file.

So the solution for me is to always exclude file names that start with a "~".