How to convert a file creationtime to localtime

S

s_sivaskanthan

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??!!

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.ToLongDateString

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

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
 
C

Cor Ligthert [MVP]

Darkie,

I assume that sending twice was a misunderstanding, however for others who
will see the given answers. 18 minutes later there is the same question from
Darkie in this newsgroup.

Please wait next time a little while if a message shows up.

Therefore I use this one with the outlook express newsreader.

news://msnews.microsoft.com/microsoft.public.dotnet.languates.vb

I hope this helps,

Cor
 

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