次の方法で共有


GetPackagePath メソッド

指定したパッケージの場所への相対パスを表す String を返します。

名前空間:  Microsoft.SqlServer.Dts.Runtime
アセンブリ:  Microsoft.SqlServer.ManagedDTS (Microsoft.SqlServer.ManagedDTS.dll)

構文

'宣言
Public Function GetPackagePath ( _
    o As Object _
) As String
'使用
Dim instance As DtsProperty
Dim o As Object
Dim returnValue As String

returnValue = instance.GetPackagePath(o)
public string GetPackagePath(
    Object o
)
public:
String^ GetPackagePath(
    Object^ o
)
member GetPackagePath : 
        o:Object -> string 
public function GetPackagePath(
    o : Object
) : String

パラメーター

戻り値

型: System. . :: . .String
指定したパッケージの場所への相対パスを表す String です。

使用例

次のコード例では、パッケージ パスを取得するさまざまな方法を示します。1 つの値は、DtsProperties コレクション内の最初のプロパティの GetPackagePath を使用して、GetPackagePath メソッドから返されます。これ以外に返されるパッケージ パスは、直接 Package で実装される GetPackagePath から返されます。出力は、メソッドから返された値を示します。

// other Using statements here...
using Microsoft.SqlServer.Dts.Runtime;
namespace DtsPropertiesTesting
{
class Program
    {

        static void Main(string[] args)
        {
            // The variable pkg points to the location
            // of the ExecuteProcess package sample 
            // that is installed with the samples.
            string packageFile = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";

            Application application = new Application();
            Package package = application.LoadPackage(packageFile, null);

            // Retrieve the information from the Properties collection.
            // Each item in the collection represents a property on the
            // Package object.

            DtsProperties properties = package.Properties;

            String propertyName;
            DTSPropertyKind propertyKind;
            String packagePath;
            TypeCode propertyType;

            foreach (DtsProperty property in properties)
            {
                propertyType = property.Type;
                propertyName = property.Name;
                propertyKind = property.PropertyKind;
                packagePath = property.GetPackagePath(package);
                Console.WriteLine("Property Type: {0}, Property Name: {1}, Property Kind: {2}, Package Path: {3} ", propertyType, propertyName, propertyKind, packagePath);
            }
        }
    }
}
' other Using statements here...
Imports Microsoft.SqlServer.Dts.Runtime
Namespace DtsPropertiesTesting
Class Program
 
        Shared  Sub Main(ByVal args() As String)
            ' The variable pkg points to the location
            ' of the ExecuteProcess package sample 
            ' that is installed with the samples.
            Dim packageFile As String =  "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx" 
 
            Dim application As Application =  New Application() 
            Dim package As Package =  application.LoadPackage(packageFile,Nothing) 
 
            ' Retrieve the information from the Properties collection.
            ' Each item in the collection represents a property on the
            ' Package object.
 
            Dim properties As DtsProperties =  package.Properties 
 
            Dim propertyName As String
            Dim propertyKind As DTSPropertyKind
            Dim packagePath As String
            Dim propertyType As TypeCode
 
            Dim property As DtsProperty
            For Each property In properties
                propertyType = property.Type
                propertyName = property.Name
                propertyKind = property.PropertyKind
                packagePath = property.GetPackagePath(package)
                Console.WriteLine("Property Type: {0}, Property Name: {1}, Property Kind: {2}, Package Path: {3} ", propertyType, propertyName, propertyKind, packagePath)
            Next
        End Sub
End Class
End Namespace

サンプルの出力 :

Package path = \Package

Package properties path = \Package.CertificateContext

Package properties path = \Package.CertificateObject

Package properties path = \Package.CheckpointFileName