今天写了个ftp文件遍历的程序,发现 两个文件的时间不对:
我服务器上有200708161.jpg 、200708162.jpg 、200708151.jpg三个文件创建时间分别为2007-8-16 8:30:30、2007-8-16 8:31:30、2007-8-15 8:30:30,我在ftp遍历的时候发现使用 FileTimeToSystemTime 转换200708151.jpg的时间是对的,二200708161.jpg的时间为2006-8-16 9:30:30 200708162.jpg的时间为 2006-8-16 9:31:30 ,请问这是什么原因啊
我服务器上有200708161.jpg 、200708162.jpg 、200708151.jpg三个文件创建时间分别为2007-8-16 8:30:30、2007-8-16 8:31:30、2007-8-15 8:30:30,我在ftp遍历的时候发现使用 FileTimeToSystemTime 转换200708151.jpg的时间是对的,二200708161.jpg的时间为2006-8-16 9:30:30 200708162.jpg的时间为 2006-8-16 9:31:30 ,请问这是什么原因啊
解决方案 »
- 在datagridview中,怎样通过选中的单元格调出该单元格对应的列名?
- 请问如何才能打印出正确的标签呢?主要是位置。
- **************数据关联的怪问题怎么又给我碰到了?
- XP下VB6打包,安装到另一XP机器时时,提示MSADO25.TLB不能注册?
- 请问有没有PB7.0英文版下载!
- 有没有办法可以不使用vb的引用,用odbc或其它方法链接sql2000数据库并修改数据
- VB创建委派的向导在哪里?
- 我创建了一个二维的动态数组,如何动态变化大小?
- sql数据库中的字段为非空,为什么在vb中还可以插入?Help!
- 奇怪的问题,相同代码,第一次出错,二次正常,过一会儿.....
- 高手帮帮我,VB操作WORD,powerpoint的问题
- 求联众多开原理
Dim bSuccess As Boolean
Dim dtFileTime As FILETIME
' Fetch time stamp from open file
bSuccess = GetFileTime(hFile, ByVal 0&, ByVal 0&, dtFileTime)
' Convert FILETIME to a VB date value
FileLastWriteTime = FileTimeToDate(dtFileTime)
End FunctionPublic Function FileLastAccessTime(ByVal hFile As Long) As Date
Dim bSuccess As Boolean
Dim dtFileTime As FILETIME
' Fetch time stamp from open file
bSuccess = GetFileTime(hFile, ByVal 0&, dtFileTime, ByVal 0&)
' Convert FILETIME to a VB date value
FileLastAccessTime = FileTimeToDate(dtFileTime)End FunctionPublic Function FileCreationTime(ByVal hFile As Long) As Date
Dim bSuccess As Boolean
Dim dtFileTime As FILETIME
' Fetch time stamp from open file
bSuccess = GetFileTime(hFile, dtFileTime, ByVal 0&, ByVal 0&)
' Convert FILETIME to a VB date value
FileCreationTime = FileTimeToDate(dtFileTime)End FunctionPublic Function FilePreciseLastWriteTime(ByVal hFile As Long) As Variant
Dim bSuccess As Boolean
Dim dtFileTime As FILETIME
' Fetch time stamp from open file
bSuccess = GetFileTime(hFile, ByVal 0&, ByVal 0&, dtFileTime)
' Convert FILETIME to a decimal value
With dtFileTime
FilePreciseLastWriteTime = MakeDecimal(.dwHighDateTime, .dwLowDateTime)
End With
End FunctionPublic Function FilePreciseLastAccessTime(ByVal hFile As Long) As Variant
Dim bSuccess As Boolean
Dim dtFileTime As FILETIME
' Fetch time stamp from open file
bSuccess = GetFileTime(hFile, ByVal 0&, dtFileTime, ByVal 0&)
' Convert FILETIME to a decimal value
With dtFileTime
FilePreciseLastAccessTime = MakeDecimal(.dwHighDateTime, .dwLowDateTime)
End With
End FunctionPublic Function FilePreciseCreationTime(ByVal hFile As Long) As Variant
Dim bSuccess As Boolean
Dim dtFileTime As FILETIME
' Fetch time stamp from open file
bSuccess = GetFileTime(hFile, dtFileTime, ByVal 0&, ByVal 0&)
' Convert FILETIME to a decimal value
With dtFileTime
FilePreciseCreationTime = MakeDecimal(.dwHighDateTime, .dwLowDateTime)
End With
End FunctionPublic Sub SetFileLastWriteTime(ByVal hFile As Long, ByVal NewValue As Variant)
Dim bSuccess As Boolean
Dim dtFileTime As FILETIME
' Fill a FILETIME structure
SetTimeValue NewValue, dtFileTime
' Save new time stamp
bSuccess = SetFileTime(hFile, ByVal 0&, ByVal 0&, dtFileTime)
End SubPublic Sub SetFileLastAccessTime(ByVal hFile As Long, ByVal NewValue As Variant)
Dim bSuccess As Boolean
Dim dtFileTime As FILETIME
' Fill a FILETIME structure
SetTimeValue NewValue, dtFileTime
' Save new time stamp
bSuccess = SetFileTime(hFile, ByVal 0&, dtFileTime, ByVal 0&)
End SubPublic Sub SetFileCreationTime(ByVal hFile As Long, ByVal NewValue As Variant)
Dim bSuccess As Boolean
Dim dtFileTime As FILETIME
' Fill a FILETIME structure
SetTimeValue NewValue, dtFileTime
' Save new time stamp
bSuccess = SetFileTime(hFile, dtFileTime, ByVal 0&, ByVal 0&)End SubPublic Function FileTimeFromDate(ByVal FromDate As Date) As FILETIME'===========================================================================
' FileTimeFromDate - Converts a VB Date data type to a FILETIME structure.
'
' NOTE: The FILETIME structure is a structure of 100-nanosecond intervals
' since January 1, 1601. The VB Date data type is a floating point value
' where the value to the left of the decimal is the number of days since
' December 30, 1899, and the value to the right of the decimal represents
' the time.
'
' FromDate The VB DAte to convert.
'
' RETURNS A date/time value in the native Win32 FILETIME structure.
'
'===========================================================================Dim Success As Boolean
Dim SysTime As SYSTEMTIME' Create SYSTEMTIME from the input date. Success = VariantTimeToSystemTime(FromDate, SysTime)
If Success Then
' Convert the SYSTEMTIME to the FILETIME
Success = SystemTimeToFileTime(SysTime, FileTimeFromDate)
End If If Not Success Then
Err.Raise Err.Number, Err.Source, Err.Description
End IfEnd FunctionPublic Function FileTimeToDate( _
FILETIME As FILETIME, _
Optional ByVal ConvertToLocal As Boolean = True) As Date'===========================================================================
' FileTimeToDate - Converts FILETIME structure to a VB Date data type.
'
' NOTE: The FILETIME structure is a structure of 100-nanosecond intervals
' since January 1, 1601. The VB Date data type is a floating point value
' where the value to the left of the decimal is the number of days since
' December 30, 1899, and the value to the right of the decimal represents
' the time.
'
' FileTime The FILETIME structure to convert.
' ConvertToLocal Optional. True to convert from UTC to local time.
'
' RETURNS A date/time value in the intrinsic VB Date data type.
'
'===========================================================================Dim Success As Boolean
Dim SysTime As SYSTEMTIME
Dim ftdouble As Double' Convert to FILETIME Success = FileTimeToSystemTime(FILETIME, SysTime)
If Success Then
' Convert to a Variant date
Success = SystemTimeToVariantTime(SysTime, ftdouble)
End If If Not Success Then
Err.Raise Err.Number, Err.Source, Err.Description
End If ' Return the result
FileTimeToDate = ftdoubleEnd FunctionPublic Sub SetTimeValue(ByVal NewValue As Variant, ByRef OutFileTime As FILETIME)'===========================================================================
' SetTimeValue - Helper function to set the various OutFILETIME fields.
'
' NewValue A date represented by a Win32FindData object, a Date
' or String datatype, or a more precise Decimal datatype.
'
' OutFILETIME Pointer to a OutFILETIME structure
'===========================================================================Dim dec As tagDECIMAL Select Case TypeName(NewValue)
Case "Win32FileTime" ' Copy all of the OutFileTime bits over
CopyMemory ByVal VarPtr(OutFileTime), NewValue.lpFileTime, _
Len(OutFileTime) Case "Decimal" ' Fill the DECIMAL structure
CopyMemory ByVal VarPtr(dec.wReserved), ByVal VarPtr(NewValue), LenB(dec) ' Fill the FILETIME structure
OutFileTime.dwHighDateTime = dec.Hi32
OutFileTime.dwLowDateTime = dec.Lo32 Case Else '"Date", "String" ' Throw error if not a date supplied
If Not IsDate(NewValue) Then
Err.Raise 5, "SetTimeValue"
End If OutFileTime = FileTimeFromDate(NewValue) End SelectEnd Sub