小编use*_*703的帖子

获取文件的最后修改日期(资源管理器值不是cmd值)

我编写了一些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 月2103: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)

excel vba last-modified excel-vba

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

excel ×1

excel-vba ×1

last-modified ×1

vba ×1