如何以检索"最后修改日期和QUOT;在ASP.Net上传的文件 [英] How to retrive "Last Modified Date" of uploaded file in ASP.Net

查看:99
本文介绍了如何以检索"最后修改日期和QUOT;在ASP.Net上传的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网站,其中客户端上传文档一样,DOCX,HTM,HTML,TXT,PDF等。我希望取回一个上传文件的最后修改日期一些文档文件。我已创建了一个处理程序(ashx的),它不保存文件的工作。

I am developing a website, in which client uploads some document files like doc, docx, htm, html, txt, pdf etc. I want to retrieve last modified date of an uploaded file. I have created one handler(.ashx) which does the job of saving the files.

Following is the code:
HttpPostedFile file = context.Request.Files[i];                                 
string fileName = file.FileName;                               
file.SaveAs(Path.Combine(uploadPath, filename));

正如你所看到的,它很简单,使用file.SaveAs()方法保存文件。但是,这HttpPostedFile类不会暴露任何属性来检索文件的最后修改日期。

As you can see, its very simple to save the file using file.SaveAs() method. But this HttpPostedFile class is not exposing any property to retrieve last modified date of file.

所以,任何人都可以告诉我怎么把它保存到硬盘之前检索文件的最后修改日期?

推荐答案

您不能做到这一点。 HTTP POST请求,但不包含上传的文件信息。

You can't do this. An HTTP post request does not contain this information about an uploaded file.

这篇关于如何以检索"最后修改日期和QUOT;在ASP.Net上传的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆