User351619809 posted
Hi All,
I am trying to get the Datetime from window explorer in my .net code. I tried to do it like this, but did not get the correct date time.
Dim test As DateTime = GetExplorerDateTime(tempFile)
Private Function GetExplorerDateTime(Filename As FileInfo) As DateTime
Dim now As DateTime = DateTime.Now
Dim localOffSet As TimeSpan = now - now.ToUniversalTime()
Return File.GetLastAccessTimeUtc(filename.Name) + localOffSet
End Function
My file in window explorer looks like this:
Name Date modified Type Size
TestFile 4/16/2015 08:08 PM Text Document 3 KB
I am trying to get 4/16/2015 08:08 PM. I tried to Google it, but none of the code seems to be getting the correct date time from the window explorer.
Any help will be greatly appreciated.