XSIUtils.BuildPath

導入

v5.0

詳細

パスの一部を 1 つ以上連ねることによって完全パスを作成します。パスの各部にはドライブ文字、サーバ名(¥¥server)、デバイス名、フォルダ名、ファイル名、および".."や"~"などの特殊記号が含まれます。

パスの各部にパスの区切り文字を含める必要はありません。BuildPath は、パスの各部の間にパスの区切り文字があることを認識しています。たとえば、BuildPath( "users", "andrew" )の場合、Windowsでは"users¥andrew"が戻され、Linuxでは"users/andrew"が戻されます。このパスを既存のファイルやフォルダを指定する必要はありません。

このメソッドは FileSystemObject.BuildPath に似ていますが、最大8 つのパス構成要素をサポートします。

BuildPath パスによりクロスプラットフォーム環境でのファイルパス/フォルダパスの扱いが容易になります。

スクリプト 構文

oReturn = XSIUtils.BuildPath( fragment1, fragment2, [fragment3], [fragment4], [fragment5], [fragment6], [fragment7], [fragment8] );

戻り値

指定されたフラグメントから構成されたパス

パラメータ

パラメータ タイプ 詳細
fragment1 String パスの最初のパート(例:"C:"または"/MyDisk")
fragment2 String パスの 2 番目のパート
fragment3 String パスに追加する任意のフラグメント

デフォルト値: ""

fragment4 String パスに追加する任意のフラグメント

デフォルト値: ""

fragment5 String パスに追加する任意のフラグメント

デフォルト値: ""

fragment6 String パスに追加する任意のフラグメント

デフォルト値: ""

fragment7 String パスに追加する任意のフラグメント

デフォルト値: ""

fragment8 String パスに追加する任意のフラグメント

デフォルト値: ""

1. JScript の例

/*
        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)

2. VBScript の例

'
'       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

関連項目

XSIUtils.Slash XSIUtils.EnsureFolderExists XSIUtils.ResolvePath