[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Change file date

Posted on 1999-11-05
5
Medium Priority
?
366 Views
Last Modified: 2008-02-01
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?

0
Comment
Question by:Neal Hartman
  • 4
5 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 2186625
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
 
LVL 10

Expert Comment

by:caraf_g
ID: 2186626
You'll find the FileTimeToSystemTime function useful!
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2186634
..and definitely the SystemTimeToFileTime function...

Check out also the SYSTEMTIME structure
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 100 total points
ID: 2186637
Actually, I think that answers your question ;-)
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2186666
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question