File Management (CFFILE)

Discussion in 'Programming' started by nanosuna, Dec 13, 2006.

  1. #1
    Hi,

    I am trying to find out the date when a text file (.txt) was last mofidied on the server (CF server). My application writes to this file which is in a cf server folder and then I need to check that the file is more than 2 days old. Anybody out there knows of an easy way to do this? :)

    Thanks,
     
    nanosuna, Dec 13, 2006 IP
  2. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #2
    <cfdirectory action="list" director="FullPathOfDirectory" filter="FileName" name="DirList">

    <cfoutput query="DirList">
    <cfif Abs(DateDiff("d",dateLastModified,Now())) GTE 2>
    <!--- do something if the dateLastModified is greater than 2 days --->
    </cfif>
    </cfoutput>

    1) <cfdirectory....Get a directory listing of the said folder and only list the said file

    2) <cfoutput query....This is for if for some strange reason the file wasn't there. That way if the file isn't there you don't run into problems later down.

    3) <cfif ABS(DateDiff.... check to see if the file is more than 2 days old

    4) if it is - DO SOMETHING!
     
    datropics, Dec 16, 2006 IP