上傳的文件是在wwwroot下 通過保存的路徑跟文件名稱完成下載
public IActionResult DownloadFile() {
var filePath = "/UploadDocuments/GET//20190422050301115.docx"; var fileName = "項目原型.docx"; FileStream fs = new FileStream(_hostingEnvironment.WebRootPath + filePath, FileMode.OpenOrCreate); fs.Close(); return File(new FileStream(_hostingEnvironment.WebRootPath + filePath, FileMode.Open), "application/octet-stream", fileName); }
