cfdirectory filters example
Example to show the usage of cfdirectory with filters.
Description: cfdirectory manages interactions with directories.
Syntax
<cfdirectory
directory = "directory name"
action = "list|create|delete|rename"
filter = "list filter"
listInfo = "name|all"
mode = "permission"
name = "query name"
newDirectory = "new directory name"
recurse = "yes|no"
sort = "sort specification"
type = "file|dir|all">
directory = "directory name"
action = "list|create|delete|rename"
filter = "list filter"
listInfo = "name|all"
mode = "permission"
name = "query name"
newDirectory = "new directory name"
recurse = "yes|no"
sort = "sort specification"
type = "file|dir|all">
Note: You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.
<!--- List all files in the current directory based on the following filters(single filter). --->
<cfset filters = "*.cfm">
<cfdirectory
action="list"
directory="#ExpandPath( '.' )#"
filter="#filters#"
listinfo="name"
name="dirlist"
/>
<!--- Output file list. --->
<cfdump var="#dirlist#" label="All cfm files">
<br>
<!--- List all files in the current directory based on the following filters(multiple filter). --->
<cfset filters = "*.cfm|*.cfc">
<cfdirectory
action="list"
directory="#ExpandPath( '.' )#"
filter="#filters#"
listinfo="name"
name="dirlist"
/>
<!--- Output file list. --->
<cfdump var="#dirlist#" label="cfm and cfc files">
<br>
<cfset filters = "*.cfm">
<cfdirectory
action="list"
directory="#ExpandPath( '.' )#"
filter="#filters#"
listinfo="name"
name="dirlist"
/>
<!--- Output file list. --->
<cfdump var="#dirlist#" label="All cfm files">
<br>
<!--- List all files in the current directory based on the following filters(multiple filter). --->
<cfset filters = "*.cfm|*.cfc">
<cfdirectory
action="list"
directory="#ExpandPath( '.' )#"
filter="#filters#"
listinfo="name"
name="dirlist"
/>
<!--- Output file list. --->
<cfdump var="#dirlist#" label="cfm and cfc files">
<br>

There are no comments for this entry.
[Add Comment]