TaskHost.GetPackagePath 方法

定义

返回任务位置的路径。

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

返回

包含包位置的字符串。

实现

示例

下面的代码示例将 Sequence 容器添加到包,然后添加一个 FileSystemTask。 使用 GetPackagePath时,将返回包 FileSystemTask 的路径。

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

namespace Microsoft.SqlServer.SSIS.Samples  
{  
    class mySample  
    {  
        static void Main(string[] args)  
        {  
            Package package = new Package();  
            Sequence seq = (Sequence)package.Executables.Add("STOCK:SEQUENCE");  

            // Add a File System task.  
            Executable eFileTask1 = seq.Executables.Add("STOCK:FileSystemTask");  
            TaskHost thFileTask1 = eFileTask1 as TaskHost;  

            // Use GetPackagePath of the TaskHost.  
            String pkgPath = thFileTask1.GetPackagePath();  
            Console.WriteLine("Package path: {0}", pkgPath);  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask  

Namespace Microsoft.SqlServer.SSIS.Samples  
    Class mySample  
        Shared  Sub Main(ByVal args() As String)  
            Dim package As Package =  New Package()   
            Dim seq As Sequence = CType(package.Executables.Add("STOCK:SEQUENCE"), Sequence)  

            ' Add a File System task.  
            Dim eFileTask1 As Executable =  seq.Executables.Add("STOCK:FileSystemTask")   
            Dim thFileTask1 As TaskHost =  eFileTask1 as TaskHost   

            ' Use GetPackagePath of the TaskHost.  
            Dim pkgPath As String =  thFileTask1.GetPackagePath()   
            Console.WriteLine("Package path: {0}", pkgPath)  
        End Sub  
    End Class  
End Namespace  

示例输出:

包路径:\Package\{4CE5CB4E-E124-4523-BE8B-D934BAF907D5}\{BFD1E4F1-53CF-4130-989E-E11FD853DA18}

适用于