public IActionResult Index() { try { var path = Directory.GetCurrentDirectory() + pathDirectory; if (!Directory.Exists(path)) { //若文件目录不存在 则创建 Directory.CreateDirectory(path); } string excelfullpath = path + excelfileName; DataTable inputdt = ExcelHelper.ExeclToDataTable(excelfullpath); string docfullpath = path + docfileName; WordHelper.DtToWord(inputdt, docfullpath); } catch (Exception ex) { } //string webRootPath = _hostingEnvironment.WebRootPath; //string contentRootPath = _hostingEnvironment.ContentRootPath; //return Content(webRootPath + "\n" + contentRootPath); //var path = Path.Combine(_hostingEnvironment.WebRootPath, "Sample.PNG"); return(View()); }