Fork me on GitHub

Activation

Enabling the XSLT extension for use in your XSLT templates. Add the following XML snippet to your ~/config/xsltExtensions.config file:

<XsltExtensions>
	...
	<ext assembly="uComponents.XsltExtensions" type="uComponents.XsltExtensions.IO" alias="ucomponents.io" />
	...
</XsltExtensions>

Methods

Here are available methods in the IO library:


DirectoryExists

Directories the exists. Returns: Returns true if the directory exists, otherwise false.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:DirectoryExists(path)" />

FileExists

Files the exists. Returns: Returns true if the file exists, otherwise false.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:FileExists(path)" />

GetDirectories

Gets the directories. Returns: Returns a node-set of the directories.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | | | searchPattern | System.String | | | allDirectories | System.Boolean | |

XSLT Example

<xsl:value-of select="ucomponents.io:GetDirectories(path, searchPattern, allDirectories)" />

GetFiles

Gets the files. Returns: Returns a node-set of the files.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | | | searchPattern | System.String | | | allDirectories | System.Boolean | |

XSLT Example

<xsl:value-of select="ucomponents.io:GetFiles(path, searchPattern, allDirectories)" />

GetExtension

Gets the extension. Returns: Returns the extension of the specified path string.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:GetExtension(path)" />

GetFileName

Gets the name of the file. Returns: Returns the file name and extension of the specified path string.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:GetFileName(path)" />

GetFileNameWithoutExtension

Gets the file name without extension. Returns: Returns the file name of the specified path string without the extension.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:GetFileNameWithoutExtension(path)" />

GetDirectoryName

Gets the name of the directory. Returns: Returns the directory name for the specified path string.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:GetDirectoryName(path)" />

GetFileSize

Gets the size of the file. Returns: Returns the filesize for the specified filepath.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:GetFileSize(path)" />

GetServerMapPath

Gets the mapped path to the server. Returns: Returns the physical file path that corresponds to the specified virtual path on the web server.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:GetServerMapPath(path)" />

MapPath

Gets the mapped path to the server. Returns: Returns the physical file path that corresponds to the specified virtual path on the web server.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | | | useHttpContext | System.Boolean | |

XSLT Example

<xsl:value-of select="ucomponents.io:MapPath(path, useHttpContext)" />

PathShortener

Truncates the middle section of a string, this is ideal for long filepaths or URLs. Returns: Returns a shortened path of the string.

Parameters

| Name | Type | Notes | |——|——|——-| | input | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:PathShortener(input)" />

FormatFileSize

Formats the size of the file.

Parameters

| Name | Type | Notes | |——|——|——-| | filesize | System.Int64 | |

XSLT Example

<xsl:value-of select="ucomponents.io:FormatFileSize(filesize)" />

LoadFile

Loads and reads the contents of a file. Returns: Returns the contents of the specified file.

Parameters

| Name | Type | Notes | |——|——|——-| | filepath | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:LoadFile(filepath)" />

GetFileInfo

Gets the FileInfo. Returns: Returns the System.IO.FileInfo for the specified filepath.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:GetFileInfo(path)" />

GetLocalFilePath

Checks if the file path is a Uri, then returns the local file path. Returns: Returns the local file path.

Parameters

| Name | Type | Notes | |——|——|——-| | path | System.String | |

XSLT Example

<xsl:value-of select="ucomponents.io:GetLocalFilePath(path)" />