如何从网站文件中读取文件创建时间? [英] How to read file creation time from website file?

查看:99
本文介绍了如何从网站文件中读取文件创建时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个需要从网站上的jpg读取文件创建时间的应用.
jpg具有恒定的文件名,但每5分钟左右更新一次.
我想下载时间并与以前下载的图像进行比较,以确定唯一性.

如何获得远程文件创建时间?

问候
Malcom

Hi
I have an app that needs to read the file creation time from a jpg on a website.
The jpg has a constant filename but is updated every 5 minutes or so.
I want to download the time and compare with the previously downloaded image to ascertain uniqueness.

How do I get the remote files creation time?

regards
Malcom

推荐答案

您不能直接这样做,但是一些技巧可能会帮助您:
HttpWebRequest 具有属性IfModifiedSince -只有从那时起,您才可以使用它来获取文件.
HttpWebResponse 具有属性LastModified.可能未设置,则为DateTime.MinValue.否则,它将显示文件的最后修改日期/时间.
如果不想在文件更改后自动下载,则可以使用HEAD 请求而不是GET 请求.
You cannot do so directly, but some tricks might help you:
HttpWebRequest has the property IfModifiedSince - you can use it to get the file only when it was modified since that time.
HttpWebResponse has the property LastModified. It might not be set, then it is DateTime.MinValue. Otherwise it shows the date/time of last modification of the file.
If you do not want to automatically download when the file changed, you can use a HEAD request instead of a GET request.


您不这样做. Web服务器(HTTP协议)没有提供文件创建或修改日期/时间的任何功能.

如果这是通过FTP连接进行的,或者服务器上有Web服务器可以从中请求此信息,则情况完全不同.
You don''t. Web servers (HTTP protocol) don''t have any facility to supply file creation or modification date/times.

If this was over an FTP connection, or if you had a web server on the server that you could request this information from, that''s a completely different story.


谢谢大家

Bernhard,感谢您的建议.我会调查的.

干杯
Malcom
Thanks guys

Bernhard, appreciate your suggestions. I''ll look into those.

Cheers
Malcom


这篇关于如何从网站文件中读取文件创建时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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