IIS Development


>  Home
>  News



>  Code Samples
>  Security


Components & Tools

>  Free Components
>  ComponentCenter
>  CodeLook Program



>  Links
>  Contact us

Search IISDEV:

AspTouch 1.0 - free

Last updated: 12/01/99, v1.0 (Initial Release)

If you are an "old dog" in the computer business, then you definitely remember the touch utilities that were around to give a file a certain date and time stamp - with a common application being setting a common date for all files of a project before it was deployed to a client. Because I didn't save the old utilities in a secure spot, I had to come up with a new solution: a component that does it for me.

The advantage of the component approach is that I can use it in a WSH script to touch multiple files, or use it from within ASP to change the timestamp of certain files. Just in case you wonder what I use it for: I have an online email archive (file based) that is searchable with Index Server, and the date selection is done via the "touched" file date of the messages (the file time is the same as the email time was).


The first method provided by AspTouch is SetToCurrentTime, and it does what the name implies to a file that is passed as parameter-changing the date and time to the current values.

Set xObj = CreateObject("AspTouch.TouchIt")

strFileName = Request.ServerVariables("SCRIPT_NAME")
strFileName = Server.MapPath(strFileName)

bRes = xObj.SetToCurrentTime(strFileName)
Response.Write "File time changed to current time"

The second method supported by AspTouch is SetFiletime, which takes two parameters: the file name and a date value. It is equally simple to use.

Set xObj = CreateObject("AspTouch.TouchIt")

strFileName = Request.ServerVariables("SCRIPT_NAME")
strFileName = Server.MapPath(strFileName)

' for demonstration purposes and that you see a difference
' mm/dd/yyy
varDateTime = "01/01/2001"

bRes = xObj.SetFiletime(strFileName,varDateTime)
Response.Write "File time set successfully!"

So far, no error handling was used in the ASP code. The following example uses full error handling:

On Error Resume Next

' you have to subtract vbObjectError to get the error number below

Set xObj = CreateObject("AspTouch.TouchIt")
If xObj Is Nothing Then
	Response.Write "Object could not be created!"
End If

strFileName = Request.ServerVariables("SCRIPT_NAME")
strFileName = Server.MapPath(strFileName)

bRes = xObj.SetFiletime(strFileName,Now())

If Err.Number <> 0 Then
	Response.Write "Error #" & err.number & " " & err.description
	Response.Write "Successfully set the new date on the current script!"
End If

Installation and Download

AspTouch is packaged for the Windows Installer Service. To be able to install the package, you need to have the Windows Installer Service running on your computer. Windows 2000 and Office 2000 automatically install it, if you don't have any of these, then you first must install the Installer Service:

Now you can download the Installer package for AspTouch, which is only 90KB in size. After downloading, simply double-click on the package to start the installation process. It automatically registers the component and installs the samples.

If you encounter problems with the package, then please report them to support@alphasierrapapa.com.


©1998-2018 Christoph Wille. All rights reserved.
All content and images on this site are copyright. Reuse (even parts) needs our written consent.