Determine Last Modified Date With the FileSystemObject

Determine Last Modified Date With the FileSystemObject

I often go to a site, scroll to the bottom, and see when it was last modified. If it says “March 1, 1825” then I am usually not so confident that the content is timely. Unfortunately, sometimes it is just the poor overworked Webmaster who has not had time to update the date on the page. Why do it manually when Microsoft provides the FileSystemObject, which can retrieve all kinds of information about files, including when it was last modified? Place this script at the bottom of your page and you’ll see what I am talking about:

 <%Set objFileSystem = CreateObject("Scripting.FileSystemObject")dir = Server.MapPath(".")'Get the files collectionSet colFiles = objFileSystem.GetFolder(dir).Files	defaultDate = #3/1/1825#latestDate = defaultDateFor Each file in colFiles	filedate = file.DateLastModified	if DateDiff("s", defaultDate, filedate) > 0 Then		latestDate = fileDate	End IfNextResponse.Write(latestDate)%>

Basically, you can retrieve the collection of files in the same directory with the FileSystemObject. Once you have that, you can determine the latest modified date by comparing the DateLastModified property versus an arbitrary date (defaultDate) for each one. Output it to the browser and you are all set.

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several