ColdFusion - How to get information about a file

GetFileInfo() - get information about a file

GetFileInfo.cfm


<!DOCTYPE html">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GetFileInfo function example: how to get information about a file</title>
</head>

<body>
<h2 style="color:Crimson">GetFileInfo Function Example: Normal</h2>

<cfset MyFile="C:\MyFolder\ReadMe.txt">

<cfoutput>
 <cfif FileExists(MyFile)>
        File: #MyFile#   
  <cfset FileInfo=GetFileInfo(MyFile)>
        <cfdump var="#FileInfo#" label="FileInfo">
        <br />
        File Name: #FileInfo.Name#
        <br />
        File Path: #FileInfo.Path#
        <br />
        File Parent Directory: #FileInfo.Parent#
        <br />
        File Type: #FileInfo.Type#
        <br />
        File Size: #FileInfo.Size#
        <br />
        File LastModified: #FileInfo.LastModified#
        <br />
        File canRead: #FileInfo.canRead#
        <br />
        File isHidden: #FileInfo.isHidden#
    <cfelse>
        File not exists #MyFile#   
    </cfif>
</cfoutput>

</body>
</html>





More ColdFusion examples