Discussion Locked

Displaying date of a file in ASP/HTML ?

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have a data extract which generates a file on a web server. This is run as a daily batch job. I would like to be able to check the date and time of this file and display the result in a web page (ASP/HTML) so that someone wanting to download it would know the last time it was updated. Is there a way ?

5 replies

by jay eckles

This shows you how to get the last modified date from a file on the server. You could assign the date to a variable and do whatever processing you want. Per your request, in this example I just print a link to the document and the date next to it .
(inspired by an example in Sams Teach Yourself ASP 3.0 in 21 Days...)

<%
Dim objFSO, objFile
Set objFSO = Server.CreateObject( "Scripting.FileSystemObject" )
Set objFile = objFSO.GetFile( Server.MapPath( "batch.out" ) )
Response.Write "batch.out "
Response.Write objFile.DateLastModified
Set objFile = nothing
Set objFSO = nothing
%>

I have not tested this, so I might have a typo in there or something, but you should get the picture.

Good luck.

Jay Eckles
www.jayeckles.com

by nikki96

If you have ASP, you have server side includes (SSI) as far as I know. Use this.

This assumes the file is named myFile.html and is in the same directory as the current file.

For specific formatting infofor the date returned (if you don't like the default) and how to specify a file not in the current directory, see
http://www.useforesite.com/tut_ssi.shtml
(remove any spaces from the url)

Nikki

by aweston2

Nikki

The above command did not work so I must conclude that SSI is not enabled on our web servers even though ASP pages run without a problem. I will look into getting SSI enabled, in the mean time I will use the ASP solution offered by Jay.

Thanks

Alan

Alan

This discussion is closed to new replies.