how to convert File Creationtime to localtime

D

d_darkie07

Hi,


I'm a newbie to VB.NET and I'm having some difficulty in viewing the
file creation time. Most links I have read do not seem to have any
problem with viewing such information, but all I get is a date in the
year 1601??!!

I want to see the localtime as I would when I sue sysdate()

Here's the code that I'm using:


------------------


Imports System.IO.File
....
Dim FileProperties As System.IO.Fileinfo(filepath)
Dim FileDate As String


FileDate =
DateTime.FromFileTime(FileProperties.CreationTime.ToFileTime).ToLocalTime.T­oLongDateString



--------------


This gives me the date as "01/01/1601 11:00 AM"


I have seen someone doing it much simpler with:


--------------


Dim fileName As String = "C:\Download\readme.txt"
Dim fileData As String
Dim fileDetails As System.IO.FileInfo = New
System.IO.FileInfo(fileName)


With fileDetails
fileData = "File was created at: " & _
.CreationTime.ToShortDateString
End With


-------------


....and apparently that was sufficinet. This doesn;t work for me either.



Any help would be much appreciated.


Thanks,
Darkie
 
H

Herfried K. Wagner [MVP]

I'm a newbie to VB.NET and I'm having some difficulty in viewing the
file creation time. Most links I have read do not seem to have any
problem with viewing such information, but all I get is a date in the
year 1601??!!

The code below seems to work fine on my machine:

\\\
MsgBox( _
New FileInfo( _
"C:\WINDOWS\Angler.bmp" _
).CreationTime.ToLocalTime.ToString() _
)
///

Which Windows version are you using? Note that this property is not
supported on Windows 98.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top