hello, I need to display the last time the site was
updated: I am trying to get FileInfo from web.config and
get a last modified year of 1600.
How do I get this info, is there a standard way?
Thank youWould the last write time be appropriate? Not sure about a standard way, but
here's one way:
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim path As String = Server.MapPath("web.config")
Dim fi1 As System.IO.FileInfo = _
New System.IO.FileInfo(path)
Label1.Text = "Last update: " & _
fi1.LastWriteTime.ToLongDateString & _
" at " & fi1.LastWriteTime.ToLongTimeString
End Sub
Does this help?
Ken
MVP [ASP.NET]
--
Microsoft MVPs have a question for *you*: Are you patched against the Worm?
http://www.microsoft.com/security/s...ns/ms03-026.asp
"szabelin" <szabelin@.szabelin> wrote in message
news:05c301c36cf5$f3d5d390$a401280a@.phx.gbl...
hello, I need to display the last time the site was
updated: I am trying to get FileInfo from web.config and
get a last modified year of 1600.
How do I get this info, is there a standard way?
Thank you
Hm.. I had it almost the same except I didn't do MapPath:
(new FileInfo("web.config")).LastWriteTime was returning
year 1600. It works with MapPath though. I am just curios
now what's year 1600 about. Thanks for help.
>--Original Message--
>Would the last write time be appropriate? Not sure about
a standard way, but
>here's one way:
> Private Sub Page_Load _
> (ByVal sender As System.Object, _
> ByVal e As System.EventArgs) _
> Handles MyBase.Load
> Dim path As String = Server.MapPath("web.config")
> Dim fi1 As System.IO.FileInfo = _
> New System.IO.FileInfo(path)
> Label1.Text = "Last update: " & _
> fi1.LastWriteTime.ToLongDateString & _
> " at " & fi1.LastWriteTime.ToLongTimeString
> End Sub
>Does this help?
>Ken
>MVP [ASP.NET]
>
>--
>Microsoft MVPs have a question for *you*: Are you patched
against the Worm?
>http://www.microsoft.com/security/s...bulletins/ms03-
026.asp
>
>"szabelin" <szabelin@.szabelin> wrote in message
>news:05c301c36cf5$f3d5d390$a401280a@.phx.gbl...
>hello, I need to display the last time the site was
>updated: I am trying to get FileInfo from web.config and
>get a last modified year of 1600.
>How do I get this info, is there a standard way?
>Thank you
>
>.
I think it's Microsoft not willing to return null objects when they should.
So they return a minimum valid date value here instead of more accurate null
object when there is no date available.
Jerry
"szabelin" <szabelin@.szabelin> wrote in message
news:0f9501c36d05$9e6c0810$a001280a@.phx.gbl...
> Hm.. I had it almost the same except I didn't do MapPath:
> (new FileInfo("web.config")).LastWriteTime was returning
> year 1600. It works with MapPath though. I am just curios
> now what's year 1600 about. Thanks for help.
>
> >--Original Message--
> >Would the last write time be appropriate? Not sure about
> a standard way, but
> >here's one way:
> > Private Sub Page_Load _
> > (ByVal sender As System.Object, _
> > ByVal e As System.EventArgs) _
> > Handles MyBase.Load
> > Dim path As String = Server.MapPath("web.config")
> > Dim fi1 As System.IO.FileInfo = _
> > New System.IO.FileInfo(path)
> > Label1.Text = "Last update: " & _
> > fi1.LastWriteTime.ToLongDateString & _
> > " at " & fi1.LastWriteTime.ToLongTimeString
> > End Sub
> >Does this help?
> >Ken
> >MVP [ASP.NET]
> >--
> >Microsoft MVPs have a question for *you*: Are you patched
> against the Worm?
> >http://www.microsoft.com/security/s...bulletins/ms03-
> 026.asp
> >"szabelin" <szabelin@.szabelin> wrote in message
> >news:05c301c36cf5$f3d5d390$a401280a@.phx.gbl...
> >hello, I need to display the last time the site was
> >updated: I am trying to get FileInfo from web.config and
> >get a last modified year of 1600.
> >How do I get this info, is there a standard way?
> >Thank you
> >.
> I am just curios now what's year 1600 about.
Maybe it was working for you, but your web.config is older than most? <just
joking!
--
Microsoft MVPs have a question for *you*: Are you patched against the Worm?
http://www.microsoft.com/security/s...ns/ms03-026.asp
"szabelin" <szabelin@.szabelin> wrote in message
news:0f9501c36d05$9e6c0810$a001280a@.phx.gbl...
Hm.. I had it almost the same except I didn't do MapPath:
(new FileInfo("web.config")).LastWriteTime was returning
year 1600. It works with MapPath though. I am just curios
now what's year 1600 about. Thanks for help.
>--Original Message--
>Would the last write time be appropriate? Not sure about
a standard way, but
>here's one way:
> Private Sub Page_Load _
> (ByVal sender As System.Object, _
> ByVal e As System.EventArgs) _
> Handles MyBase.Load
> Dim path As String = Server.MapPath("web.config")
> Dim fi1 As System.IO.FileInfo = _
> New System.IO.FileInfo(path)
> Label1.Text = "Last update: " & _
> fi1.LastWriteTime.ToLongDateString & _
> " at " & fi1.LastWriteTime.ToLongTimeString
> End Sub
>Does this help?
>Ken
>MVP [ASP.NET]
>
>--
>Microsoft MVPs have a question for *you*: Are you patched
against the Worm?
>http://www.microsoft.com/security/s...bulletins/ms03-
026.asp
>
>"szabelin" <szabelin@.szabelin> wrote in message
>news:05c301c36cf5$f3d5d390$a401280a@.phx.gbl...
>hello, I need to display the last time the site was
>updated: I am trying to get FileInfo from web.config and
>get a last modified year of 1600.
>How do I get this info, is there a standard way?
>Thank you
>
>.
You are right they are returning 'DateTime.MinValue' since
struct objects can't be null :)
I'd rather they had something like DateTime.NotSet and so
subsequent calls would throw exception ...
>--Original Message--
>I think it's Microsoft not willing to return null objects
when they should.
>So they return a minimum valid date value here instead of
more accurate null
>object when there is no date available.
>Jerry
>"szabelin" <szabelin@.szabelin> wrote in message
>news:0f9501c36d05$9e6c0810$a001280a@.phx.gbl...
>>
>> Hm.. I had it almost the same except I didn't do
MapPath:
>> (new FileInfo("web.config")).LastWriteTime was returning
>> year 1600. It works with MapPath though. I am just
curios
>> now what's year 1600 about. Thanks for help.
>>
>>
>>
>> >--Original Message--
>> >Would the last write time be appropriate? Not sure
about
>> a standard way, but
>> >here's one way:
>>> > Private Sub Page_Load _
>> > (ByVal sender As System.Object, _
>> > ByVal e As System.EventArgs) _
>> > Handles MyBase.Load
>> > Dim path As String = Server.MapPath("web.config")
>> > Dim fi1 As System.IO.FileInfo = _
>> > New System.IO.FileInfo(path)
>> > Label1.Text = "Last update: " & _
>> > fi1.LastWriteTime.ToLongDateString & _
>> > " at " & fi1.LastWriteTime.ToLongTimeString
>> > End Sub
>>> >Does this help?
>>> >Ken
>> >MVP [ASP.NET]
>>>> >--
>> >Microsoft MVPs have a question for *you*: Are you
patched
>> against the Worm?
>>
>http://www.microsoft.com/security/s...bulletins/ms03-
>> 026.asp
>>>>> >"szabelin" <szabelin@.szabelin> wrote in message
>> >news:05c301c36cf5$f3d5d390$a401280a@.phx.gbl...
>> >hello, I need to display the last time the site was
>> >updated: I am trying to get FileInfo from web.config
and
>> >get a last modified year of 1600.
>>> >How do I get this info, is there a standard way?
>>> >Thank you
>>>> >.
>>
>.
Struct objects can't be null, you're right (but having an "invalid" or
not-set value as you suggest would help). But the reason is elsewhere. If
you read .NET SDK Microsoft suggests that you do not return null objects.
The reason they give is that whoever will call your method will not bother
checking for null objects. If you have .NET SDK installed take a look at
ms-help://MS.NETFrameworkSDKv1.1/cpgenref/html/cpconarrayusageguidelines.htm
, last paragraph says this:
--------------
String and Array properties should never return a null reference. Null can
be difficult to understand in this context. For example, a user might assume
that the following code will work.
[C#]
public void DoSomething()
{
string s = SomeOtherFunc();
if (s.Length > 0)
{
// Do something else.
}
}
The general rule is that null, empty string (""), and empty (0 item) arrays
should be treated the same way. Return an empty array instead of a null
reference.
--------------
Wonder why Microsoft's software has so many security issues when they assume
the code above should work and suggest that developers do not bother
checking return values.
I personally don't agree with this, classic example is
XmlElement.GetAttribute which should return null if the specified attribute
doesn't exist and an empty string if it exists but is empty.
Jerry
"szabelin" <szabelin@.szabelin> wrote in message
news:01e301c36d91$f5602430$a401280a@.phx.gbl...
> You are right they are returning 'DateTime.MinValue' since
> struct objects can't be null :)
> I'd rather they had something like DateTime.NotSet and so
> subsequent calls would throw exception ...
>
>
> >--Original Message--
> >I think it's Microsoft not willing to return null objects
> when they should.
> >So they return a minimum valid date value here instead of
> more accurate null
> >object when there is no date available.
> >Jerry
> >"szabelin" <szabelin@.szabelin> wrote in message
> >news:0f9501c36d05$9e6c0810$a001280a@.phx.gbl...
> >>
> >> Hm.. I had it almost the same except I didn't do
> MapPath:
> >> (new FileInfo("web.config")).LastWriteTime was returning
> >> year 1600. It works with MapPath though. I am just
> curios
> >> now what's year 1600 about. Thanks for help.
> >>
> >>
> >>
> >> >--Original Message--
> >> >Would the last write time be appropriate? Not sure
> about
> >> a standard way, but
> >> >here's one way:
> >> >> > Private Sub Page_Load _
> >> > (ByVal sender As System.Object, _
> >> > ByVal e As System.EventArgs) _
> >> > Handles MyBase.Load
> >> > Dim path As String = Server.MapPath("web.config")
> >> > Dim fi1 As System.IO.FileInfo = _
> >> > New System.IO.FileInfo(path)
> >> > Label1.Text = "Last update: " & _
> >> > fi1.LastWriteTime.ToLongDateString & _
> >> > " at " & fi1.LastWriteTime.ToLongTimeString
> >> > End Sub
> >> >> >Does this help?
> >> >> >Ken
> >> >MVP [ASP.NET]
> >> >> >> >--
> >> >Microsoft MVPs have a question for *you*: Are you
> patched
> >> against the Worm?
> >>
> >http://www.microsoft.com/security/s...bulletins/ms03-
> >> 026.asp
> >> >> >> >> >"szabelin" <szabelin@.szabelin> wrote in message
> >> >news:05c301c36cf5$f3d5d390$a401280a@.phx.gbl...
> >> >hello, I need to display the last time the site was
> >> >updated: I am trying to get FileInfo from web.config
> and
> >> >get a last modified year of 1600.
> >> >> >How do I get this info, is there a standard way?
> >> >> >Thank you
> >> >> >> >.
> >> >.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment