- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用一个函数来检查远程计算机上文件的时间戳。我们有很多电脑。
我遇到的事情有点奇怪。
我在很多计算机上运行查询。 Computer26887 上的时间戳显示为“1/4/2013 12:46:01 AM”
我 UNC 到那台计算机并检查文件。在资源管理器中,时间戳显示“9/16/2013 11:23 AM”(一个半小时前)嗯....
再次查询 - 旧的,错误的,时间戳。我右键单击该文件,转到属性并单击属性窗口中的“详细信息”-“修改日期 9/16/2013 11:23 AM”
使用 vb 代码再次查询 - 现在它显示了正确的时间戳????
我有数百个系统要通过,如果我不能相信我得到的数据,我有太多的工作要做!!!
有任何想法吗?
更新
基本上,VB.NET 正在检索时间戳的缓存版本。时间戳已更新,但缓存仍保留旧时间戳。如何在不手动打开资源管理器中文件属性的情况下强制更新缓存?
Shared Function GetFileInfo(ByVal ComputerName As String, ByVal FiletoFind As String, info As String)
Dim Ret As String = ""
Dim targetfile = "\\" & ComputerName & "\" & FiletoFind
Dim fi As FileInfo = New FileInfo(targetfile)
If fi.Exists Then
fi.refresh
Select Case info
Case Is = "Exists"
Ret = fi.Exists.ToString
Case Is = "Delete"
fi.Delete()
Ret = fi.Exists.ToString
Case Is = "Created"
Ret = fi.CreationTime.ToString("MM/dd/yyyy hh:mm:ss tt")
Case Is = "Access"
Ret = fi.LastAccessTime.ToString("MM/dd/yyyy hh:mm:ss tt")
Case Is = "Mod"
Ret = fi.LastWriteTime.ToString("MM/dd/yyyy hh:mm:ss tt")
End Select
Else
Ret = "File Not Found"
End If
Ret = Ret.Replace(vbCrLf, "")
Ret = Ret.Replace(vbCr, "")
Return Ret
End Function
File
而不是
FileInfo
...查看帖子历史记录)
Func _timestampchk($path)
Dim $file,$astamp
$file = $path
$astamp = FileGetTime($file, 0, 0)
If IsArray($astamp) Then
$stamp = $astamp[1] & "/" & $astamp[2] & "/" & $astamp[0] & " " & $astamp[3] & ":" & $astamp[4]
ElseIf $astamp = 0 Then
$stamp = "File " & $path & " not Found"
Else
$stamp = 0
EndIf
Return $stamp
EndFunc ;==>_timestampchk
最佳答案
尝试 FileSystem.GetFileInfo ,正如 Andrew Morton 和 neoistheone 所指出的
Dim information = My.Computer.FileSystem.GetFileInfo("C:\MyLogFile.log")
information.Refresh() ' Calls must be made to Refresh before attempting to get the attribute information, or the information will be outdated.
MsgBox("The file's full name is " & information.FullName & ".")
MsgBox("Last access time is " & information.LastAccessTime & ".")
MsgBox("The length is " & information.Length & ".")
Declare Function GetFileTime Lib "kernel32.dll" (ByVal hFile _
As Long, lpCreationTime As FILETIME, lpLastAccessTime _
As FILETIME, lpLastWriteTime As FILETIME) As Long
'#VBIDEUtils#***********************************************
' * Programmer Name : Waty Thierry
' * Web Site : www.geocities.com/ResearchTriangle/6311/
' * E-Mail : waty.thierry@usa.net
' * Date : 28/06/99
' * Time : 13:16
' ********************************************************
' * Comments : Showing the Properties dialog box
' *
' * This tip demonstrates how To use the Win32 API To
' * bring up the explorer properties
' * dialog box For a specified file.
' * This API Function has the same effect As Right
' * clicking On a file In Windows 95 And selecting properties.
' **************************************************
Option Explicit On
Private Type SHELLEXECUTEINFO
cbSize As Long
fMask As Long
hwnd As Long
lpVerb As String
lpFile As String
lpParameters As String
lpDirectory As String
nShow As Long
hInstApp As Long
lpIDList As Long
lpClass As String
hkeyClass As Long
dwHotKey As Long
hIcon As Long
hProcess As Long
End Type
Private Const SEE_MASK_INVOKEIDLIST = &HC
Private Const SEE_MASK_NOCLOSEPROCESS = &H40
Private Const SEE_MASK_FLAG_NO_UI = &H400
Private Declare Function ShellExecuteEX Lib "shell32.dll" Alias _
"ShellExecuteEx" (SEI As SHELLEXECUTEINFO) As Long
Public Function ShowProps(FileName As String, _
OwnerhWnd As Long) As Boolean
'USAGE:
'To show the properties dialog box of "c:\autoexec.bat", use the following code:
'Call ShowProps("c:\autoexec.bat", Me.hwnd)
'Function will return false if
'property windows can't be shown for
'any reason (e.g., invalid file or Ownerhwnd)
On Error Resume Next
Dim SEI As SHELLEXECUTEINFO
Dim r As Long
With SEI
.cbSize = Len(SEI)
.fMask = SEE_MASK_NOCLOSEPROCESS Or _
SEE_MASK_INVOKEIDLIST Or SEE_MASK_FLAG_NO_UI
.hwnd = OwnerhWnd
.lpVerb = "properties"
.lpFile = FileName
.lpParameters = vbNullChar
.lpDirectory = vbNullChar
.nShow = 0
.hInstApp = 0
.lpIDList = 0
End With
r = ShellExecuteEX(SEI)
ShowProps = r
End Function
关于.net - GetLastWriteTime 不准确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18849803/
我正在使用一个函数来检查远程计算机上文件的时间戳。我们有很多电脑。 我遇到的事情有点奇怪。 我在很多计算机上运行查询。 Computer26887 上的时间戳显示为“1/4/2013 12:46:01
我有一个 aspx 页面,我在其中显示代码下方,但我不知道问题出在哪里,因为它没有正确显示修改后的日期。 预计显示日期:05/05/2016当前日期显示:12/31/1600 好吧,400 年前我没有
我有以下代码行: 在资源管理器中,文件显示为在 1/2/2012 被修改。但是此代码输出 1600-01-02。 最佳答案 您看到的原因是: If the file described in the
所以我需要列出一堆文件名和它们的 LastWriteTime。以下代码是我如何获得稍后打印的 LastWriteTime。 DateTime lDate = File.GetLastWriteTime
我创建了一个性能文件 (.blg) 并开始收集性能参数。 文件修改日期从未在 Windows 资源管理器上更新,它始终显示创建日期,如下所示,但随着时间的推移文件大小在增加。 现在我想获取文件创建数据
我编写了一个工具,用于在工具用户指定的时间窗口内收集日志文件。到目前为止,我是通过使用 File.GetLastWriteTime 方法在日志文件上收集日志文件,将其与用户输入的时间进行比较,并根据这
我正在使用以下代码将目录的修改日期时间写入标签 string selectedPath = comboBox1.SelectedItem.ToString(); DateTime lastdate =
我是一名优秀的程序员,十分优秀!