Return to doc.sitecore.com

Documentation

The File Xsl Extension allows extracting such file information as file size, modification date and so on.

1.  Installation

The File Xsl Extension is distributed as a standard Sitecore package. Thus to start using it, you should install the package. Please refer to the Installing Modules and Packages article if you are not familiar with the standard Sitecore Packager tool.

The package installs the sitecore.xslhelpers.fileext.dll assembly to the /bin folder of your solution root.

Add the following definition into the <xslExtensions> section of the web.config file:

<extension mode="on" type="Sitecore.XslHelpers.FileExt, Sitecore.XslHelpers.FileExt" namespace="http://www.sitecore.net/file" />

2.  User Manual

Add attribute into the <xsl:stylesheet> node of the xsl file where you want to use this extention.

The extension is used like any common XSL extension. For example:

<xsl:value-of select="sc:CreationTime ('C:\dir\file.exe')"/>
<xsl:value-of select="sc:CreationTime ('/upload/image1.jpg')"/>

Function overview:

 

CreationTime(string fileName) Returns creation date and time of the specified file in ISO format.
DirectoryName(string fileName) Returns a string which contains the full path to a specified file.
Exists(string fileName) Determines whether the specified file exists (returns ‘true’ or ’false’).
Extension(string fileName) Returns a string which contains the extension of the specified file.
FileSize(string filename, bool useKb) Returns the size of the specified file (in bytes or kilobytes, 0 – bytes, 1 - kilobytes).
FullName(string fileName) Returns the full name of the specified file.
LastAccessTime(string fileName) Returns the last access time of the specified file in ISO format.
LastWriteTime(string fileName) Returns the last write time of the current file in ISO format.
MapPath(string fileName) Returns the physical path to the specified file.
FileIcon(string filename, bool largeIcon) Returns the icon file path for specified file (0 – for small icon, 1 – for large icon)

Valid function arguments include: