Finding a files date and time

In ASP I would make a connection to an external DLL that Microsoft supplies now called the FileSystemObject that I would then use the glean a files date and time stamp.  I also know that I can use this same DLL with CF.  However, I would like a pure CF solution if one is available.  I looked briefly at CFFILE but I am not sure that I will be able to use this to gathter the information I seek.  Suggestions on how I can use a pure CF solution to find the file date of a given file.

Actually what I am trying to accomplish is put a "Last Update: <file date>" for the page that is currently being viewed so that I can always tell, and so the surfer can as well, when that file was last posted...to put a finer point on it.

Thanks for any help you all can provide.
LVL 1
beregothAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
nathansConnect With a Mentor Commented:
<CFDIRECTORY
    DIRECTORY="c:\"
    NAME="mydirectory"
    SORT="size ASC, name DESC, datelastmodified" filter="test.bat">


The Filter can filter to find one file.

Nathan
nathan@nsnd.com




PS... here is another thing you might want.
<CFIF FileExists("#path##filename#.doc")>
File does Exist!
</cfif>
0
 
benjaFLCommented:
<CFDIRECTORY
    DIRECTORY="c:\winnt\system32"
    NAME="mydirectory"
    SORT="size ASC, name DESC, datelastmodified">

<CFOUTPUT QUERY="mydirectory">
    Name: #mydirectory.name# <BR>
    Size: #mydirectory.size# <BR>
    Type: #mydirectory.type# <BR>
    Date last modified: #mydirectory.datelastmodified# <BR>
    Attributes: #mydirectory.attributes#<BR>
    Mode: #mydirectory.mode#<BR>
</CFOUTPUT>

Returning the datelastmodified should do what you want.
0
 
beregothAuthor Commented:
Perfect...one question though...this technique you are using...the CFDIRECTORY command...I am assuming that this is basically a type of query, which is why you are using the CFOUTPUT QUERY tag to get all the files from the CFDIRECTORY result set....

I need only one file from the current directory...can I specify a WHERE clause or is there  FILENAME attribute so that I can clue in to one file, which will always be in the current files directory ("." I am assuming instead of specifying a directory)?
0
 
beregothAuthor Commented:
1000 pardons to benjaFL, and perhaps it was my fault to not being as precise as I should have been, but your answer was copied directly from the manual and did not actually accomplish what I was trying to do.  It led me in the right direction, but Nathan's answer was right on the money...I did eventually figure out that the filter is what I needed to use and got it working fine...but this was the answer I was looking for...besides, 50 points is not worth trying to split.

I'll give benjaFL the benefit of the doubt next time.

Thanks nathans
0
All Courses

From novice to tech pro — start learning today.