BUG: VBApp FileCopy Updates Destination File's Date & Time StampLast reviewed: July 29, 1997Article ID: Q113958 |
The information in this article applies to:
SYMPTOMSThe FileCopy statement in Visual Basic, Applications Edition does not maintain the Date and Time stamp of the source file when the destination file is copied. Unlike the MS-DOS Copy command and the FileCopy statement in Visual Basic version 3.0, the time stamp of the destination file shows the actual time the copy occurs.
WORKAROUNDBecause the time stamp placed on the file is based on the current time, setting the system time to the time stamp of the source file prior to copying the file establishes the same time stamp on the destination file. Below is a sample piece of code to copy a file that maintains the same time stamp:
Sub TestFileCopy() Dim datOriginalDateTime As Date Dim datSourceTimeStamp As Date Const cSourceFile = "C:\AUTOEXEC.BAT" Const cDestFile = "C:\AUTOEXEC.OLD" ' Obtain Date/Time Stamp of the Source file: datSourceTimeStamp = FileDateTime(cSourceFile) ' Store Current time in a temporary variable: datOriginalDateTime = Now() ' Set System time to that of the Source File: Date = datSourceTimeStamp Time = datSourceTimeStamp FileCopy cSourceFile, cDestFile ' Restore System time to correct time: Date = datOriginalDateTime Time = datOriginalDateTime MsgBox "Source Date = " & FileDateTime(cSourceFile) & Chr(13) & _ Chr(10) & "Destination Date = " & FileDateTime(cDestFile) End Sub STATUSMicrosoft has confirmed this to be a bug in the products listed above. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATION
Steps to Reproduce Problem
|
Additional query words: buglist1.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |