ASP Is there a way to change a file modification date?

Hello. I'm allowing for the uploading of files from my webpages on a Windows environment.  When the file is uploaded, it does not retain the date of the original file and I'm trying to find someway to "touch" it with the original date.  Other than using the touch.exe program (which is not allowed to be installed on our server), is there another way to do this?

Why is it that you can create serverside files, but you can't modify the dates on those files?

Thanks all!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
And, I do believe that is a limitation with ASP.

Naveen SwamyYash Infinite Solutions Private LimitedCommented:
thts possible in php
create a dll or with a function that changes the filedatetime and incorporate iit in asp with server.createobject

M.Naveen Swamy

just call  touch("yourfilenamewithpath", #date#)

Private Type FILETIME
        dwLowDateTime As Long
        dwHighDateTime As Long
End Type

        wYear As Integer
        wMonth As Integer
        wDayOfWeek As Integer
        wDay As Integer
        wHour As Integer
        wMinute As Integer
        wSecond As Integer
        wMilliseconds As Integer
End Type

'Made private to prevent namespace pollution

Private Const GENERIC_WRITE = &H40000000
Private Const FILE_SHARE_READ = &H1
Private Const OPEN_EXISTING = 3

Private Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime As SYSTEMTIME, lpFileTime As FILETIME) As Long
Private Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime As FILETIME, lpLocalFileTime As FILETIME) As Long
Private Declare Function LocalFileTimeToFileTime Lib "kernel32" (lpLocalFileTime As FILETIME, lpFileTime As FILETIME) As Long
Private Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, _
    ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Any, _
    ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
Private Declare Function SetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Public Function Touch(ByVal sFileName As String, ByVal dDate As Date) As Boolean
Dim hFile As Long
Dim iResult As Long

Dim lpCreationTime As FILETIME
Dim lpLastAccessTime As FILETIME
Dim lpLastWriteTime As FILETIME
Dim lpLocalFileTime As FILETIME
Dim lpSystemTime As SYSTEMTIME

        With lpSystemTime
            .wDay = Day(dDate)
            .wMonth = Month(dDate)
            .wYear = Year(dDate)
            .wHour = Hour(dDate)
            .wMinute = Minute(dDate)
            .wSecond = Second(dDate)
        End With
        iResult = SystemTimeToFileTime(lpSystemTime, lpLocalFileTime)
        If iResult Then
            iResult = GetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime)
            If iResult Then
                iResult = LocalFileTimeToFileTime(lpLocalFileTime, lpLastWriteTime)
                If iResult Then
                    iResult = SetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime)
                    Touch = CBool(iResult)
                    Touch = False
                End If
               Touch = False
            End If
            Touch = False
        End If
        CloseHandle hFile
       Touch = False
    End If
End Function

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
la_signorina_quyAuthor Commented:
Hi, sorry been out of commission,  thanks for the responses.  I've found the following short and sweet solution and it works fine.

Function Touch(ByVal strParentPath, ByVal strFile, ByVal strDate)
      Dim objShell
      Set objShell = CreateObject("Shell.Application")
      If (Not objShell IS Nothing) Then
            Dim objFolder2
            Set objFolder2 = objShell.NameSpace(strParentPath)
            If (Not objFolder2 IS Nothing) Then
                  Dim objFolderItem
                  Set objFolderItem = objFolder2.ParseName(strFile)
                  If (Not objFolderItem IS Nothing) Then
                        Dim szReturn
                        szReturn = objFolderItem.ModifyDate
                        objFolderItem.ModifyDate = strDate
                  End If
                  Set objFolderItem = Nothing
            End If
            Set objFolder2 = Nothing
            End If
      Set objShell = Nothing
End Function
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.