Package.GetPackagePath Méthode

Définition

Retourne une valeur qui contient le chemin d'accès relatif à l'emplacement du package.

public:
 virtual System::String ^ GetPackagePath();
public string GetPackagePath ();
abstract member GetPackagePath : unit -> string
override this.GetPackagePath : unit -> string
Public Function GetPackagePath () As String

Retours

String

Valeur qui contient le chemin d'accès relatif à l'emplacement du package.

Implémente

Exemples

L’exemple de code suivant montre comment récupérer le chemin du package.

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Tasks.ScriptTask;  

namespace Package_API  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Application app = new Application();  
            Package pkg = new Package();  
            pkg = app.LoadPackage(@"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx", null);  
            // Show the package path.  
            Console.WriteLine("Package Path: {0}", pkg.GetPackagePath());  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Tasks.ScriptTask  

Namespace Package_API  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim app As Application =  New Application()   
            Dim pkg As Package =  New Package()   
            pkg = app.LoadPackage("C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx", Nothing)  
            ' Show the package path.  
            Console.WriteLine("Package Path: {0}", pkg.GetPackagePath())  
        End Sub  
    End Class  
End Namespace  

Exemple de sortie :

Package Path: \Package

Remarques

Il existe plusieurs façons d’utiliser la GetPackagePath méthode. En plus de la méthode indiquée dans la section Exemple, GetPackagePath vous pouvez appeler toutes les propriétés du package et retourner le chemin d’accès à n’importe quelle propriété. L’exemple de code suivant montre les appels aux GetPackagePath propriétés dans les premières, deuxième et troisième positions de la Properties collection.

String prop = p2.Properties[0].GetPackagePath(p2);  
Console.WriteLine("Package properties path = " + prop);  

prop = p2.Properties[1].GetPackagePath(p2);  
Console.WriteLine("Package properties path = " + prop);  

prop = p2.Properties[2].GetPackagePath(p2);  
Console.WriteLine("Package properties path = " + prop);  

Exemple de sortie :

Package path = \Package

Package properties path = \Package.CertificateContext

Package properties path = \Package.CertificateObject

Package properties path = \Package.CheckpointFileName

S’applique à