Closed Tich1212 closed 3 years ago
For now I am just catching the exception, providing a message, and exiting.
catch (Exception e) {
Console.WriteLine(e.Message +"\n");
Console.WriteLine("An issue occurred reading the xlsx file, \n" +
"Please save and close the file then try again");
Console.WriteLine("Press ENTER to exit.........");
ConsoleKeyInfo keyInfo = Console.ReadKey();
while (keyInfo.Key != ConsoleKey.Enter)
keyInfo = Console.ReadKey();
System.Environment.Exit(0);
return rval; //Making compiler happy
}
Instead of an exit, maybe we could have the user hit enter to try and read it again.
Addressed with Pull Request #15
How: If the given excel fil is open we make a copy of the excel file in the user's temp directory and read that one instead
System.IO.IOException: 'The process cannot access the file 'C:\Users\q0hecemt\source\repos\ExcelToCWMS\ExcelToCWMSTests\bin\Debug\input.xlsx' because it is being used by another process.'
This exception was originally thrown at this call stack: [External Code] ExcelToCWMS.ClosedXML.GetDataTable(string) in ClosedXML.cs ExcelToCWMS.ProcessDataTable.GetTimeSeriesFromExcel(string, string, System.DateTime, System.DateTime) in ProcessDataTable.cs ExcelToCWMS.Tests.ProcessDataTableTests.GetTimeSeriesFromExcelTest() in ProcessDataTableTests.cs