【发布时间】:2023-04-09 01:21:01
【问题描述】:
我正在开发一个网站,其中客户端上传一些文档文件,如 doc、docx、htm、html、txt、pdf 等。我想检索上传文件的最后修改日期。我创建了一个处理程序(.ashx)来完成保存文件的工作。
Following is the code:
HttpPostedFile file = context.Request.Files[i];
string fileName = file.FileName;
file.SaveAs(Path.Combine(uploadPath, filename));
如您所见,使用 file.SaveAs() 方法保存文件非常简单。但是这个 HttpPostedFile 类没有公开任何属性来检索文件的最后修改日期。
谁能告诉我如何在将文件保存到硬盘之前检索文件的最后修改日期?
【问题讨论】: