I work on web api asp.net core 2.2
I face issue I can't return true or false from web api compare excel as below
so if excel is identical then return true else return false
[HttpGet]
[Route("CompareExcel")]
public IActionResult CompareExcel()
{
var DisplayFileName = Request.Form.Files[0];
string fileName = DisplayFileName.FileName.Replace(".xlsx", "-") + Guid.NewGuid().ToString() + ".xlsx";
string Month = DateTime.Now.Month.ToString();
string DirectoryCreate = Path.Combine(myValue1, Month);// myValue1 + "\\" + Month + "\\" + fileName;
CExcel ex = new CExcel();
string error = "";
int rowCount = 0;
var filedata = ContentDispositionHeaderValue.Parse(Request.Form.Files[0].ContentDisposition).FileName.Trim('"');
var dbPath = Path.Combine(DirectoryCreate, fileName);
var InputfilePath = System.IO.Path.Combine(GetFilesDownload, "Gen.xlsx");
using (var stream = new FileStream(dbPath, FileMode.Create))
{
Request.Form.Files[0].CopyTo(stream);
stream.Flush();
stream.Close();
}
GC.Collect();
bool areIdentical = ex.CompareExcel(dbPath, InputfilePath, out rowCount, out error);
if (areIdentical == true)
{
// return true
}
else
{
// return false
}
}