howto: read file last modified date/time.

View: New views
3 Messages — Rating Filter:   Alert me  

howto: read file last modified date/time.

by Phil Sayers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

I don't see an out-of-the-box nant file function to read the last modified
date/time of a file into a property.  The opposite of the 'touch' task.
I checked nantcontrib and I didn't see anything there (unless I missed it)

Is anyone away of an existing library or code snippet I can copy/paste that
may accommodate this before I go an re-invent the wheel?

Thanks
Phil


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
NAnt-users mailing list
NAnt-users@...
https://lists.sourceforge.net/lists/listinfo/nant-users

Re: howto: read file last modified date/time.

by Bob Archer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

YEs, use the file:: functions. There is one to get the create date and one to get the modify date.

file::get-last-write-time() is what you are looking for as far as I can tell.

BOb


> -----Original Message-----
> From: Phil Sayers [mailto:phil@...]
> Sent: Tuesday, August 11, 2009 11:22 AM
> To: nant-users@...
> Subject: [NAnt-users] howto: read file last modified date/time.
>
> Hi
>
> I don't see an out-of-the-box nant file function to read the last
> modified
> date/time of a file into a property.  The opposite of the 'touch' task.
> I checked nantcontrib and I didn't see anything there (unless I missed
> it)
>
> Is anyone away of an existing library or code snippet I can copy/paste
> that
> may accommodate this before I go an re-invent the wheel?
>
> Thanks
> Phil
>
>
> -----------------------------------------------------------------------
> -------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> NAnt-users mailing list
> NAnt-users@...
> https://lists.sourceforge.net/lists/listinfo/nant-users

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
NAnt-users mailing list
NAnt-users@...
https://lists.sourceforge.net/lists/listinfo/nant-users

Re: howto: read file last modified date/time.

by Phil Sayers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Apologies, I should have been more specific...

I needed to get the last modified date/time in a specific format, as part of
building an xml file.
I ended up with a dirty script task that looks like this.

<script language="vb" prefix="FuncLib">
                <code>
                <![CDATA[

                <[Function]("GetFileLastModifiedDate")> _
                public shared function GetFileLastModifiedDate(filepath as
String) as String
                        return new
System.IO.FileInfo(filepath).LastWriteTimeUtc.ToString("s")
                End Function

                ]]>
                </code>
        </script>

Anyway...thanks for the help, problem solved.

-----Original Message-----
From: Bob Archer [mailto:Bob.Archer@...]
Sent: Monday, August 17, 2009 11:54 AM
To: Phil Sayers; nant-users@...
Subject: Re: [NAnt-users] howto: read file last modified date/time.

YEs, use the file:: functions. There is one to get the create date and one
to get the modify date.

file::get-last-write-time() is what you are looking for as far as I can
tell.

BOb


> -----Original Message-----
> From: Phil Sayers [mailto:phil@...]
> Sent: Tuesday, August 11, 2009 11:22 AM
> To: nant-users@...
> Subject: [NAnt-users] howto: read file last modified date/time.
>
> Hi
>
> I don't see an out-of-the-box nant file function to read the last
> modified
> date/time of a file into a property.  The opposite of the 'touch' task.
> I checked nantcontrib and I didn't see anything there (unless I missed
> it)
>
> Is anyone away of an existing library or code snippet I can copy/paste
> that
> may accommodate this before I go an re-invent the wheel?
>
> Thanks
> Phil
>
>
> -----------------------------------------------------------------------
> -------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> NAnt-users mailing list
> NAnt-users@...
> https://lists.sourceforge.net/lists/listinfo/nant-users

----------------------------------------------------------------------------
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
NAnt-users mailing list
NAnt-users@...
https://lists.sourceforge.net/lists/listinfo/nant-users


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
NAnt-users mailing list
NAnt-users@...
https://lists.sourceforge.net/lists/listinfo/nant-users