v5.0
Builds a full path by concatenating one or more path fragments.
Path fragments include drive letters, server names ("\\server"),
device names, folder names, file names, and special symbols such as
".." and "~".
Path fragments do not need to include a path separator character.
BuildPath makes sure there is a single path separator character
between each part of the path. For example, BuildPath( "users",
"andrew" ) returns "users\andrew" on Windows and "users/andrew" on
Linux. The path does not need to specify an existing file or
folder.
This method is similar to FileSystemObject.BuildPath, but supports
up to eight path fragments.
BuildPath makes it easier to write cross-platform scripting code
that deals with file and folder paths.
oReturn = XSIUtils.BuildPath( fragment1, fragment2, [fragment3], [fragment4], [fragment5], [fragment6], [fragment7], [fragment8] ); |
A path composed from the specified fragments
Parameter | Type | Description |
---|---|---|
fragment1 | String | The first part of a path (for example, "C:" or "/MyDisk") |
fragment2 | String | The second part of the path |
fragment3 | String | An optional fragment to append to the path.
Default Value: "" |
fragment4 | String | An optional fragment to append to the path.
Default Value: "" |
fragment5 | String | An optional fragment to append to the path.
Default Value: "" |
fragment6 | String | An optional fragment to append to the path.
Default Value: "" |
fragment7 | String | An optional fragment to append to the path.
Default Value: "" |
fragment8 | String | An optional fragment to append to the path.
Default Value: "" |
/* This example shows how to use XSIUtils.BuildPath to build the full path to the user's Script folder. This code works on both Linux and Windows machines. */ var strScriptsPath = XSIUtils.BuildPath( Application.InstallationPath( siUserPath ), "Data", "Scripts" ) ; var aScriptFiles = FindFilesInFolder( strScriptsPath, ".*\.js$", true, false ) ; Application.LogMessage( strScriptsPath + " : " + aScriptFiles.length + " JScript script(s)") ; aScriptFiles = FindFilesInFolder( strScriptsPath, ".*\.vbs$", true, false ) ; Application.LogMessage( strScriptsPath + " : " + aScriptFiles.length + " VBScript script(s)") ; aScriptFiles = FindFilesInFolder( strScriptsPath, ".*\.py?$", true, false ) ; Application.LogMessage( strScriptsPath + " : " + aScriptFiles.length + " Python script(s)") ; // Running this example counts the number of scripts in your user path: // INFO : <user_path>\Data\Scripts : 19 JScript script(s) // INFO : <user_path>\Data\Scripts : 25 VBScript script(s) // INFO : <user_path>\Data\Scripts : 6 Python script(s) |
' ' This example shows how to use XSIUtils.BuildPath ' strUserPath = Application.InstallationPath( siUserPath ) strRelativePath = XSIUtils.BuildPath( "MyFolder", "MySubFolder" & 1, "foo.txt" ) strFullPath = XSIUtils.BuildPath( strUserPath, strRelativePath ) Application.LogMessage strUserPath Application.LogMessage strRelativePath Application.LogMessage strFullPath |