Package.ExportConfigurationFile(String) 메서드

정의

패키지의 모든 배포 가능한 변수를 포함하는 XML 파일을 만듭니다.

public:
 void ExportConfigurationFile(System::String ^ str);
public void ExportConfigurationFile (string str);
member this.ExportConfigurationFile : string -> unit
Public Sub ExportConfigurationFile (str As String)

매개 변수

str
String

구성 파일의 경로입니다.

예제

다음 예제에서는 새 패키지를 만들고, 속성을 설정하고 EnableConfigurationstrue, 설정합니다 ExportConfigurationFile . 그런 다음 패키지에 새 구성을 추가하고 , ConfigurationTypePackagePath.ConfigurationString

static void Main(string[] args)  
        {  
            // Create a package and set two properties.  
            Package pkg = new Package();  
            pkg.EnableConfigurations = true;  
            pkg.ExportConfigurationFile(@"C:\conf.xml");  

            // Create a variable object and add it to the   
            // package Variables collection.  
            Variable varPkg = pkg.Variables.Add("var", false, "", 100);  
            varPkg.Value = 1;  
            string packagePathToVariable = varPkg.GetPackagePath();  

            // Create a configuration object and add it to the   
           // package configuration collection  
            Configuration config = pkg.Configurations.Add();  

           // Set properties on the configuration object.  
            config.ConfigurationString = "conf.xml";  
            config.ConfigurationType = DTSConfigurationType.ConfigFile;  
            config.PackagePath = packagePathToVariable;  

            //save the package and its configuration  
            Application app = new Application();  
            app.SaveToXml(@"c:\pkg.xml", pkg, null);  

            //Reload the package  
            Package p1 = app.LoadPackage(@"c:\pkg.xml", null);  
            //Review its Variables collection  
            Console.WriteLine("The value of variable VAR = " + p1.Variables["var"].Value);  
        }  
Shared  Sub Main(ByVal args() As String)  
            ' Create a package and set two properties.  
            Dim pkg As Package =  New Package()   
            pkg.EnableConfigurations = True  
            pkg.ExportConfigurationFile("C:\conf.xml")  

            ' Create a variable object and add it to the   
            ' package Variables collection.  
            Dim varPkg As Variable =  pkg.Variables.Add("var",False,"",100)   
            varPkg.Value = 1  
            Dim packagePathToVariable As String =  varPkg.GetPackagePath()   

            ' Create a configuration object and add it to the   
           ' package configuration collection  
            Dim config As Configuration =  pkg.Configurations.Add()   

           ' Set properties on the configuration object.  
            config.ConfigurationString = "conf.xml"  
            config.ConfigurationType = DTSConfigurationType.ConfigFile  
            config.PackagePath = packagePathToVariable  

            'save the package and its configuration  
            Dim app As Application =  New Application()   
            app.SaveToXml("c:\pkg.xml", pkg, Nothing)  

            'Reload the package  
            Dim p1 As Package =  app.LoadPackage("c:\pkg.xml",Nothing)   
            'Review its Variables collection  
            Console.WriteLine("The value of variable VAR = " + p1.Variables("var").Value)  
End Sub  

샘플 출력:

The value of variable VAR = 1

설명

구성 파일을 편집하고 컴퓨터 종속 변수의 값을 변경할 수 있습니다. 패키지를 다른 컴퓨터에 배포할 때마다 실행할 때 해당 컴퓨터에서 컴퓨터 종속 변수를 사용합니다. 자세한 내용은 패키지 구성 만들기를 참조하세요.

적용 대상