VBA 从文本文件的属性中获取日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5970191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA Getting date from properties of a text file
提问by Jesse Smothermon
I'm trying to grab the date that a specific text file was uploaded onto the computer. The date isn't in the actual text file, instead you have to right-click then go to properties to view the date. I need to read the date into a variable.
我正在尝试获取特定文本文件上传到计算机上的日期。日期不在实际的文本文件中,您必须右键单击然后转到属性以查看日期。我需要将日期读入一个变量。
I have no idea where to start to try and get this done.
我不知道从哪里开始尝试完成这项工作。
Thank you,
谢谢,
Jesse Smothermon
杰西·斯莫瑟蒙
回答by Alex K.
If the built in FileDateTime()
isnt what your after you can use the FSO:
如果内置FileDateTime()
不是您可以使用 FSO 后的内容:
Dim FSO As Object: Set FSO = CreateObject("Scripting.FileSystemObject")
Dim objFile As Object: Set objFile = FSO.Getfile("C:\bleep\bloop.file")
Debug.Print "Date created: " & objFile.DateCreated
Debug.Print "Date last accessed: " & objFile.DateLastAccessed
Debug.Print "Date last modified: " & objFile.DateLastModified
If its a date in an extended attribute check thisout.
如果它是扩展属性中的日期,请检查这一点。