Search

April 15, 2016

FileExists

This function can be used to test the existence of a file.

 

Example 1:

«SetVr('fileName',concat(Directory,'\ExtraTemplate.xdtpx'))»
«If(FileExists(GetV('fileName')))»
«MergeTemplate(GetV('fileName'))»
«End(if exists)»

This will construct the name of a file in the XpressDox variable named ‘fileName’, and, if the file exists, issue the MergeTemplate command for it.  Without the test for existence, if the file did NOT exist, the MergeTemplate would fail with an error message.

 

Example 2:

Include a file, but first test to see whether that file exists.

«IncludeFileData(.\Datasets\<MatterID>.xddata.xml,Refresh,,,FileExists(concat(‘.Datasets\’,MatterID,’.xddata.xml’)))»

IncludeFileData cannot be subject to an If condition, but the command itself does take a condition as shown above.