Change file date

How can I change the modification date and time of a file? The SetFileTime API requires that the date/time be converted to:

Type FILETIME
        dwLowDateTime As Long
        dwHighDateTime As Long
End Type

How is a date/time (Now) converted to this?

LVL 1
Neal HartmanAsked:
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.

caraf_gCommented:
From the MSDN help...

FILETIME
This structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601.

At a Glance
Header file: Winbase.h
Windows CE versions: 1.0 and later


Syntax
typedef struct _FILETIME { // ft
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME;

Members
dwLowDateTime
Specifies the low 32 bits of the Win32 date/time value.
dwHighDateTime
Specifies the upper 32 bits of the Win32 date/time value.
Remarks
The FILETIME data structure is used in the time conversion functions between MS-DOS and Win32.

See Also
CompareFileTime, FileTimeToLocalFileTime, FileTimeToSystemTime, GetFileTime, LocalFileTimeToFileTime, SetFileTime, SystemTimeToFileTime

 
0
caraf_gCommented:
You'll find the FileTimeToSystemTime function useful!
0
caraf_gCommented:
..and definitely the SystemTimeToFileTime function...

Check out also the SYSTEMTIME structure
0
caraf_gCommented:
Actually, I think that answers your question ;-)
0

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
Erick37Commented:
From
http://www.mvps.org/vb/index2.html?samples.htm
FileInfo.zip

Private Function DoubleToFileTime(ftDbl As Double, Optional Universalize As Boolean = True) As FILETIME
   Dim ft As FILETIME
   Dim st As SYSTEMTIME
   '
   ' Convert double to systemtime structure.
   '
   With st
      .wYear = Year(ftDbl)
      .wMonth = Month(ftDbl)
      .wDay = Day(ftDbl)
      .wDayOfWeek = WeekDay(ftDbl) - 1
      .wHour = Hour(ftDbl)
      .wMinute = Minute(ftDbl)
      .wSecond = Second(ftDbl)
   End With
   '
   ' Convert systemtime to filetime structure.
   '
   Call SystemTimeToFileTime(st, ft)
   '
   ' Convert local time to UTC time, if requested.
   '
   If Universalize Then
      Call LocalFileTimeToFileTime(ft, DoubleToFileTime)
   Else
      DoubleToFileTime = ft
   End If
End Function
0
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
Visual Basic Classic

From novice to tech pro — start learning today.