Hi have been struggling with this issue for the last 2 days, and cannot seem to figure out what the problem is, I have seen the other related posts on this but none of the are directly related the way I implemented my code, I am not using a Stream-reader/Writer I am simply copying the file to the folder specified, I tried to close the file reader after I read the file but that did not help either, I am out of ideas, can anyone please guide me on this code or perhaps suggest another efficient way to implement this. The file is by no means open in another location.
public ActionResult Upload(HttpPostedFileBase file)
{
List<CleanSupplierClaim> supplierClaimsData = new List<CleanSupplierClaim>();
try
{
if (file.ContentLength > 0)
{
if (file.FileName.EndsWith("xls") || file.FileName.EndsWith("xlsx")) ;
string path = AppDomain.CurrentDomain.BaseDirectory
+ "upload\\" + file.FileName;
if (System.IO.File.Exists(path))
{
System.IO.File.Delete(path);
}
file.SaveAs(path);
Excel.Application application = new Excel.Application();
Excel.Workbook workbook = application.Workbooks.Open(path);
Excel.Worksheet worksheet = workbook.ActiveSheet;
Excel.Range range = worksheet.UsedRange;