<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312977#M59235</link>
    <description>Yeah,&lt;BR /&gt;
I'm okay with it now, I really didn't care about the create date - I was&lt;BR /&gt;
just surprised when it was coming up after the save date and it started me&lt;BR /&gt;
worrying whether I could trust the save date, cause I'm wanting to use this&lt;BR /&gt;
for backing up/ syncing my working files and will be depending on the&lt;BR /&gt;
reported save times to decide which files get overwritten/updated&lt;BR /&gt;
like you say, it does make sense once I realized they were copies of older&lt;BR /&gt;
files.&lt;BR /&gt;
Thanks again&lt;BR /&gt;
Mark&lt;BR /&gt;
&lt;BR /&gt;
"wivory" &lt;WAYNEI&gt; wrote in message&lt;BR /&gt;
news:f19de7f.3@WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; It does have some peverse logic when you think about it. The new file was&lt;BR /&gt;
created when you copied it, but it was last modified when you modified the&lt;BR /&gt;
original.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Wayne&lt;/WAYNEI&gt;</description>
    <pubDate>Wed, 19 Nov 2003 20:35:02 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2003-11-19T20:35:02Z</dc:date>
    <item>
      <title>windows file dates inherently unreliable?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312972#M59230</link>
      <description>Hi,&lt;BR /&gt;
looking at file dates with win api&lt;BR /&gt;
below is a sample printout at end of function after reading a directory of&lt;BR /&gt;
files:&lt;BR /&gt;
&lt;BR /&gt;
C:\vb\z.bas&lt;BR /&gt;
Created:  9/5/2003 15:4:20:981&lt;BR /&gt;
Last Accessed:  9/5/2003 15:4:20:991&lt;BR /&gt;
Last saved:  1/30/2003 3:1:52:0&lt;BR /&gt;
Done files...&lt;BR /&gt;
Out of 822 files, there were 731 with saved date before created date&lt;BR /&gt;
That took: 0.24 seconds&lt;BR /&gt;
&lt;BR /&gt;
why would created date be later than last saved date?&lt;BR /&gt;
if created date is unreliable is saved date at least accurate?&lt;BR /&gt;
anyone can shed some light on this?&lt;BR /&gt;
tia&lt;BR /&gt;
mark</description>
      <pubDate>Tue, 18 Nov 2003 00:07:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312972#M59230</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-11-18T00:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: windows file dates inherently unreliable?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312973#M59231</link>
      <description>I've seen this before and whilst I've never seen confirmation anywhere, I deduced myself that it can occur when you copy a file,  So if you modify z.bas on January 30th and then copy it to another directory on September 5th I think the new file would exhibit these properties.  &lt;BR /&gt;&lt;BR /&gt;
  &lt;BR /&gt;&lt;BR /&gt;
Regards  &lt;BR /&gt;&lt;BR /&gt;
  &lt;BR /&gt;&lt;BR /&gt;
Wayne Ivory  &lt;BR /&gt;&lt;BR /&gt;
IT Analyst Programmer  &lt;BR /&gt;&lt;BR /&gt;
Wespine Industries Pty Ltd  &lt;BR /&gt;</description>
      <pubDate>Tue, 18 Nov 2003 17:44:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312973#M59231</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-11-18T17:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: windows file dates inherently unreliable?</title>
      <link>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312974#M59232</link>
      <description>Please post the code you used to generate the information.&lt;BR /&gt;
&lt;BR /&gt;
Joe&lt;BR /&gt;
--</description>
      <pubDate>Wed, 19 Nov 2003 08:51:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312974#M59232</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-11-19T08:51:42Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312975#M59233</link>
      <description>"joesu" &lt;JOESU&gt; wrote in message&lt;BR /&gt;
news:f19de7f.1@WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; Please post the code you used to generate the information.&lt;BR /&gt;
&amp;gt; Joe&lt;BR /&gt;
&amp;gt; --&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&lt;BR /&gt;
i think this is most of it,&lt;BR /&gt;
some is in a class mod cmnFile.cls&lt;BR /&gt;
the calling sub is in a test module.&lt;BR /&gt;
(some of the declares are for other parts of the class, not all are used in&lt;BR /&gt;
this example)&lt;BR /&gt;
'**** this stuff in cls mod&lt;BR /&gt;
  'adapted from example by:&lt;BR /&gt;
    'KPD-Team 2001&lt;BR /&gt;
    'URL: http://www.allapi.net/&lt;BR /&gt;
    'E-Mail: KPDTeam@allapi.net&lt;BR /&gt;
'as well as info gleaned from msdn&lt;BR /&gt;
'compare file times&lt;BR /&gt;
Private Type FILETIME&lt;BR /&gt;
    dwLowDateTime As Long&lt;BR /&gt;
    dwHighDateTime As Long&lt;BR /&gt;
End Type&lt;BR /&gt;
Private Type SYSTEMTIME&lt;BR /&gt;
    wYear As Integer&lt;BR /&gt;
    wMonth As Integer&lt;BR /&gt;
    wDayOfWeek As Integer&lt;BR /&gt;
    wDay As Integer&lt;BR /&gt;
    wHour As Integer&lt;BR /&gt;
    wMinute As Integer&lt;BR /&gt;
    wSecond As Integer&lt;BR /&gt;
    wMilliseconds As Integer&lt;BR /&gt;
End Type&lt;BR /&gt;
Private Type WIN32_FIND_DATA&lt;BR /&gt;
    dwFileAttributes As Long&lt;BR /&gt;
    ftCreationTime As FILETIME&lt;BR /&gt;
    ftLastAccessTime As FILETIME&lt;BR /&gt;
    ftLastWriteTime As FILETIME&lt;BR /&gt;
    nFileSizeHigh As Long&lt;BR /&gt;
    nFileSizeLow As Long&lt;BR /&gt;
    dwReserved0 As Long&lt;BR /&gt;
    dwReserved1 As Long&lt;BR /&gt;
    cFileName As String * MAX_PATH&lt;BR /&gt;
    cAlternate As String * 14&lt;BR /&gt;
End Type&lt;BR /&gt;
&lt;BR /&gt;
Private Type BY_HANDLE_FILE_INFORMATION&lt;BR /&gt;
    dwFileAttributes As Long&lt;BR /&gt;
    ftCreationTime As FILETIME&lt;BR /&gt;
    ftLastAccessTime As FILETIME&lt;BR /&gt;
    ftLastWriteTime As FILETIME&lt;BR /&gt;
    dwVolumeSerialNumber As Long&lt;BR /&gt;
    nFileSizeHigh As Long&lt;BR /&gt;
    nFileSizeLow As Long&lt;BR /&gt;
    nNumberOfLinks As Long&lt;BR /&gt;
    nFileIndexHigh As Long&lt;BR /&gt;
    nFileIndexLow As Long&lt;BR /&gt;
End Type&lt;BR /&gt;
'declare winapi functions&lt;BR /&gt;
Private Declare Function SearchTreeForFile Lib "IMAGEHLP.DLL" (ByVal&lt;BR /&gt;
lpRootPath As String, ByVal lpInputName As String, ByVal lpOutputName As&lt;BR /&gt;
String) As Long&lt;BR /&gt;
Private Declare Function GetFileInformationByHandle Lib "kernel32" (ByVal&lt;BR /&gt;
hFile As Long, lpFileInformation As BY_HANDLE_FILE_INFORMATION) As Long&lt;BR /&gt;
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA"&lt;BR /&gt;
(ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal&lt;BR /&gt;
dwShareMode As Long, lpSecurityAttributes As Any, ByVal&lt;BR /&gt;
dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal&lt;BR /&gt;
hTemplateFile As Long) As Long&lt;BR /&gt;
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long)&lt;BR /&gt;
As Long&lt;BR /&gt;
Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long,&lt;BR /&gt;
lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As&lt;BR /&gt;
FILETIME) As Long&lt;BR /&gt;
Private Declare Function FileTimeToSystemTime Lib "kernel32" (lpFileTime As&lt;BR /&gt;
FILETIME, lpSystemTime As SYSTEMTIME) As Long&lt;BR /&gt;
Private Declare Function FileTimeToLocalFileTime Lib "kernel32" (lpFileTime&lt;BR /&gt;
As FILETIME, lpLocalFileTime As FILETIME) As Long&lt;BR /&gt;
&lt;BR /&gt;
Private Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime&lt;BR /&gt;
As SYSTEMTIME, lpFileTime As FILETIME) As Long&lt;BR /&gt;
Private Declare Function CompareFileTime Lib "kernel32" (lpFileTime1 As&lt;BR /&gt;
FILETIME, lpFileTime2 As FILETIME) As Long&lt;BR /&gt;
&lt;BR /&gt;
Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA"&lt;BR /&gt;
(ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long&lt;BR /&gt;
Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA"&lt;BR /&gt;
(ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long&lt;BR /&gt;
Private Declare Function GetFileAttributes Lib "kernel32" Alias&lt;BR /&gt;
"GetFileAttributesA" (ByVal lpFileName As String) As Long&lt;BR /&gt;
Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long)&lt;BR /&gt;
As Long&lt;BR /&gt;
&lt;BR /&gt;
Public Sub GetFileTimes(ByVal sFileName As String, ByRef colRtn As&lt;BR /&gt;
Collection)&lt;BR /&gt;
'file handle&lt;BR /&gt;
Dim lngFhndl As Long&lt;BR /&gt;
'file times&lt;BR /&gt;
Dim ftCreated As FILETIME&lt;BR /&gt;
Dim ftLastAccess As FILETIME&lt;BR /&gt;
Dim ftSaved As FILETIME&lt;BR /&gt;
'local time&lt;BR /&gt;
Dim ftlCreated As FILETIME&lt;BR /&gt;
Dim ftlLastAccess As FILETIME&lt;BR /&gt;
Dim ftlSaved As FILETIME&lt;BR /&gt;
'system time&lt;BR /&gt;
Dim ftsCreated As SYSTEMTIME&lt;BR /&gt;
Dim ftsLastAccess As SYSTEMTIME&lt;BR /&gt;
Dim ftsSaved As SYSTEMTIME&lt;BR /&gt;
&lt;BR /&gt;
'get handle&lt;BR /&gt;
lngFhndl = GetFileHandle(sFileName)&lt;BR /&gt;
'fill in filetime structures&lt;BR /&gt;
GetFileTime lngFhndl, ftCreated, ftLastAccess, ftSaved&lt;BR /&gt;
'close handle&lt;BR /&gt;
CloseFile (lngFhndl)&lt;BR /&gt;
&lt;BR /&gt;
'Convert the file times to the local file time&lt;BR /&gt;
FileTimeToLocalFileTime ftCreated, ftlCreated&lt;BR /&gt;
FileTimeToLocalFileTime ftLastAccess, ftlLastAccess&lt;BR /&gt;
FileTimeToLocalFileTime ftSaved, ftlSaved&lt;BR /&gt;
&lt;BR /&gt;
'Convert the file times to system file time&lt;BR /&gt;
FileTimeToSystemTime ftlCreated, ftsCreated&lt;BR /&gt;
FileTimeToSystemTime ftlLastAccess, ftsLastAccess&lt;BR /&gt;
FileTimeToSystemTime ftlSaved, ftsSaved&lt;BR /&gt;
&lt;BR /&gt;
'cant pass a systemtime structure so convert to string&lt;BR /&gt;
Dim sCreated As String&lt;BR /&gt;
Dim sAccessed As String&lt;BR /&gt;
Dim sSaved As String&lt;BR /&gt;
&lt;BR /&gt;
'add strings to byref return collection argument/parameter&lt;BR /&gt;
colRtn.Add GetTimeString(ftsCreated)&lt;BR /&gt;
colRtn.Add GetTimeString(ftsLastAccess)&lt;BR /&gt;
colRtn.Add GetTimeString(ftsSaved)&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
Private Function GetTimeString(ByRef sFileTime As SYSTEMTIME) As String&lt;BR /&gt;
Dim sTime As String&lt;BR /&gt;
    sTime = Str$(sFileTime.wMonth) _&lt;BR /&gt;
    + "/" + LTrim(Str$(sFileTime.wDay)) _&lt;BR /&gt;
    + "/" + LTrim(Str$(sFileTime.wYear)) _&lt;BR /&gt;
    + " " + LTrim(Str$(sFileTime.wHour)) _&lt;BR /&gt;
    + ":" + LTrim(Str$(sFileTime.wMinute)) _&lt;BR /&gt;
    + ":" + LTrim(Str$(sFileTime.wSecond)) _&lt;BR /&gt;
    + ":" + LTrim(Str$(sFileTime.wMilliseconds))&lt;BR /&gt;
  GetTimeString = sTime&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Private Function GetFileHandle(ByVal sFileName As String) As Long&lt;BR /&gt;
    Dim hFile As Long&lt;BR /&gt;
    'create a handle to the file&lt;BR /&gt;
    hFile = CreateFile(sFileName, 0, 0, ByVal 0&amp;amp;, OPEN_EXISTING, 0, ByVal&lt;BR /&gt;
0&amp;amp;)&lt;BR /&gt;
    'return file handle&lt;BR /&gt;
    GetFileHandle = hFile&lt;BR /&gt;
End Function&lt;BR /&gt;
'******end of cls mod&lt;BR /&gt;
&lt;BR /&gt;
'*********this in test module&lt;BR /&gt;
Sub testgetfiles()&lt;BR /&gt;
&lt;BR /&gt;
Dim cd As cmnDebug&lt;BR /&gt;
Set cd = New cmnDebug&lt;BR /&gt;
cd.DebugOn = True&lt;BR /&gt;
&lt;BR /&gt;
Dim cF As cmnFile&lt;BR /&gt;
Set cF = New cmnFile&lt;BR /&gt;
&lt;BR /&gt;
Dim sDirA As String&lt;BR /&gt;
sDirA = "C:\0\0code\vb\"&lt;BR /&gt;
&lt;BR /&gt;
Dim vRtn As Variant&lt;BR /&gt;
'get list of files&lt;BR /&gt;
vRtn = cF.GetFilesAPI(sDirA, "*")&lt;BR /&gt;
&lt;BR /&gt;
Dim lb As Integer&lt;BR /&gt;
Dim ub As Integer&lt;BR /&gt;
lb = LBound(vRtn)&lt;BR /&gt;
ub = UBound(vRtn)&lt;BR /&gt;
Dim iNumfiles As Integer&lt;BR /&gt;
iNumfiles = ub - lb + 1&lt;BR /&gt;
Dim icount As Integer&lt;BR /&gt;
icount = 0&lt;BR /&gt;
&lt;BR /&gt;
Dim i As Integer&lt;BR /&gt;
Dim sCreatedA As String&lt;BR /&gt;
Dim sAccessedA As String&lt;BR /&gt;
Dim sSavedA As String&lt;BR /&gt;
&lt;BR /&gt;
Dim j As Integer&lt;BR /&gt;
&lt;BR /&gt;
For i = lb To ub&lt;BR /&gt;
'fresh collection ea time&lt;BR /&gt;
Dim colRes As New Collection&lt;BR /&gt;
  cF.GetFileTimes sDirA &amp;amp; vRtn(i), colRes&lt;BR /&gt;
  sCreatedA = colRes(1)&lt;BR /&gt;
  sAccessedA = colRes(2)&lt;BR /&gt;
  sSavedA = colRes(3)&lt;BR /&gt;
  If sCreatedA &amp;gt; sSavedA Then&lt;BR /&gt;
  icount = icount + 1&lt;BR /&gt;
  End If&lt;BR /&gt;
    'clear collection&lt;BR /&gt;
    Set colRes = Nothing&lt;BR /&gt;
Next&lt;BR /&gt;
  cd.dp sDirA &amp;amp; vRtn(i - 1)&lt;BR /&gt;
  cd.dp "Created: " &amp;amp; sCreatedA&lt;BR /&gt;
  cd.dp "Last Accessed: " &amp;amp; sAccessedA&lt;BR /&gt;
  cd.dp "Last saved: " &amp;amp; sSavedA&lt;BR /&gt;
  cd.dp "out of " &amp;amp; iNumfiles &amp;amp; " files, there were " &amp;amp; icount &amp;amp; " with&lt;BR /&gt;
saved date before created date"&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
cd.dp is basically debug.print with a boolean switch for on or off.&lt;BR /&gt;
(in another .cls)&lt;BR /&gt;
fwiw I think wayne is right about the copying of a file updating it's&lt;BR /&gt;
created date, but not saved date. which explains my results.&lt;BR /&gt;
thanks all&lt;BR /&gt;
Mark&lt;/JOESU&gt;</description>
      <pubDate>Wed, 19 Nov 2003 19:33:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312975#M59233</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-11-19T19:33:08Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312976#M59234</link>
      <description>It does have some peverse logic when you think about it.  The new file was created when you copied it, but it was last modified when you modified the original.  &lt;BR /&gt;&lt;BR /&gt;
  &lt;BR /&gt;&lt;BR /&gt;
Wayne</description>
      <pubDate>Wed, 19 Nov 2003 20:21:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312976#M59234</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-11-19T20:21:44Z</dc:date>
    </item>
    <item>
      <title>Re:</title>
      <link>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312977#M59235</link>
      <description>Yeah,&lt;BR /&gt;
I'm okay with it now, I really didn't care about the create date - I was&lt;BR /&gt;
just surprised when it was coming up after the save date and it started me&lt;BR /&gt;
worrying whether I could trust the save date, cause I'm wanting to use this&lt;BR /&gt;
for backing up/ syncing my working files and will be depending on the&lt;BR /&gt;
reported save times to decide which files get overwritten/updated&lt;BR /&gt;
like you say, it does make sense once I realized they were copies of older&lt;BR /&gt;
files.&lt;BR /&gt;
Thanks again&lt;BR /&gt;
Mark&lt;BR /&gt;
&lt;BR /&gt;
"wivory" &lt;WAYNEI&gt; wrote in message&lt;BR /&gt;
news:f19de7f.3@WebX.maYIadrTaRb...&lt;BR /&gt;
&amp;gt; It does have some peverse logic when you think about it. The new file was&lt;BR /&gt;
created when you copied it, but it was last modified when you modified the&lt;BR /&gt;
original.&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&amp;gt; Wayne&lt;/WAYNEI&gt;</description>
      <pubDate>Wed, 19 Nov 2003 20:35:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/windows-file-dates-inherently-unreliable/m-p/312977#M59235</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2003-11-19T20:35:02Z</dc:date>
    </item>
  </channel>
</rss>

