FileSystemObject vs System.IO.File

  • Thread starter Thread starter google_groups3
  • Start date Start date
G

google_groups3

Hi all,

I am slowly re-writing old VB6 code to VB.NET. I have 1 problem. I
was using FileSystemObject to return the modified timestamp of a
file, all worked well.

When I use System.IO.File.GetLastWriteTime(MyFile).ToShortTimeString
the time is 1 hour behind that of the file. For example, I look in
Windows Explorer and see that the time stamp is 11:24.
System.IO.File.GetLastWriteTime(MyFile).ToShortTimeString reports it
at 10:24 though.

The system clock is set correctly and also if i test it with FSO, it
reports the same time as Windows Explorer. What is wrong???

Thanks,
Steve
 
I can see your point because I wrote a simple function & that displays the
time one hour earlier than explorer too. Take a look below:

Private Function GetFileLastWriteTime(ByVal sFile As String) As DateTime
Dim fiFile As New IO.FileInfo(sFile)
Dim dtFile As Date = fiFile.LastWriteTime
Return dtFile.ToShortTimeString
End Function
 
Crouchie1998 said:
I can see your point because I wrote a simple function & that displays the
time one hour earlier than explorer too. Take a look below:

Private Function GetFileLastWriteTime(ByVal sFile As String) As DateTime
Dim fiFile As New IO.FileInfo(sFile)
Dim dtFile As Date = fiFile.LastWriteTime
Return dtFile.ToShortTimeString
End Function

exactly. I have not yet tried it with the FileInfo class as Cor
suggests, although I expect it to be the same because of the
specifications on MSDN. 1 question crouchie, what are your Regional
Settings? i.e. Which time zone are you set to? I am set to +1 and of
course the clocks went forward this weekend! I would be curious to
know if this happens to people with GMT or a different time zone to me.
I can only think that it is a bug as FSO reports it just fine. Of
course, the problem with FSO is that it isn't .NET!

Any help appreciated.
 
Hi,

GMT is always the same, even in Greenwich where British Summer Time is used.

Cor
 
Clocks in the US spring forward next Sunday. Are there countries where the
shift to Daylight Savings Time has occurred already?

Mike Ober.
 
Clocks already changed here in Madrid and it causes the same problem for me!
Is it the same for people in the UK anyone?
 
???? I never said it was not Cor. I merely stated that I have the same
problem and I live in Spain AND the clocks here have already gone forward.

Sarcasm is the lowest form of wit.
 
Daniel,

This is a developers newsgroup. I wrote 5 hours before you, that the time
was changed in the EU.

Your message looked therefore for me as this kind of code

If Country = EU then
'time is changed
ElseIf
State = Spain
'time is changed
End if

And that kind of code I don't like, because it is only confusing pretending
if Spain is not a state of the EU and when it is absolute useless.

Therefore my message.

Cor
 
Cor. When replying to Michael D. Ober I provided more information that just
a region of the world that the clocks have already changed. So, instead of
just saying "EU on Easter Saterday/Sunday" I stated where I live, the fact
that the clocks have changed and importantly, the fact that I have the same
problem with this.

Far more helpful than your post. So please, if you want to start a petty
argument or flame war, please do it with somebody else. It is a shame when
people use these forums to irritate people.

If you wish to discuss this further, you can email me directly rather than
wasting people precious bandwidth by posting here. Or maybe you can read it
better this way:

If DiscussSubjectFurther = True Then
EmailMeDirect = True
Else
Exit Thread
End IF

p.s. 5 hours is not that great a time difference when posting to groups.
Although I am using a newsreader to post, sometimes I use Google and that
can take many more hours than 5 for new messages to appear, often meaning
that 2 different people can reply to the same post without knowing about it.
 
Daniel,

I did not noticed that it where flames from you to irritate me, glad that
you made me attend on it.

Therefore my last message.

Cor
 
I suspect this problem will clear starting April 2nd. If so, this appears
to be a bug in the regional settings of the .NET runtime and should be
reported to the Visual Studio team. - V 2.0 is in beta so now's the time to
get this fixed.

Mike Ober.
 

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

Back
Top