我编写了一些Excel VBA代码,用于将文件名,版本和上次修改日期/时间添加到工作表中.该代码似乎工作正常,除了有时文件的时间部分Last Modified Date将从我在资源管理器窗口中看到的正好向前或向后1小时.
我注意到,如果执行dir命令,我的代码返回的值与cmd窗口中显示的修改日期/时间相同.
例如,如果我在system32文件夹中查找dbghelp.dll文件:
C:\Windows\System32>dir dbghelp.*
Volume in drive C has no label.
Volume Serial Number is 16E8-4159
Directory of C:\Windows\System32
21/11/2010 04:24 1,087,488 dbghelp.dll
1 File(s) 1,087,488 bytes
0 Dir(s) 60,439,101,440 bytes free
C:\Windows\System32>
Run Code Online (Sandbox Code Playgroud)
但是,资源管理器窗口中的相同文件显示修改时间为2010年11 月21日03:24 - 提前1小时.
我写的代码是返回cmd窗口时间,而我想要Explorer窗口时间:
Sub GetFileDetails()
Dim path As String
Dim objFSO As Object
Dim objFile As Object
Dim objFolder As Object
Dim loopCount As Integer
Dim pathCheck As Boolean …Run Code Online (Sandbox Code Playgroud)